How to get sun direction for whole day?

I want to show sunlight from sunrise to sunset in my application. For that I need sunrise time , sunset time and direction of sunlight at each hour/interval. I can get sunrise and sunset time from shadow info. How to get the direction of sun light at each hour ? I’m open to other solution also .

Sketchup.active_model.shadow_info.each {|k,v| puts "#{k}:#{v}"}

City:Boulder (CO)
Country:USA
Dark:45
DayOfYear:48
DaylightSavings:false
DisplayNorth:false
DisplayOnAllFaces:true
DisplayOnGroundPlane:true
DisplayShadows:false
EdgesCastShadows:false
Latitude:40.018309
Light:80
Longitude:-105.242139
NorthAngle:0.0
ShadowTime:2019-02-17 12:12:32 +0530
ShadowTime_time_t:1550385752
SunDirection:(0.9712478375635323, -0.23406079968387353, -0.04351068925572213)
SunRise:2019-02-17 12:25:51 +0530
SunRise_time_t:1550386551
SunSet:2019-02-17 23:04:20 +0530
SunSet_time_t:1550424860
TZOffset:-7.0
UseSunForAllShading:true

You want to know the direction of the sun, and you notice that shadow info contains a vector SunDirection. This is for the current time and date, so you need to set the current time to a different time (for each hour) by setting ShadowTime and then reading the updated vector.

require 'date'

d1 = DateTime.new(shadow_info['SunRise'])
d2 = DateTime.new(shadow_info['SunSet'])
start_full_hour = DateTime.new(d1.year, d1.month, d1.day, d1.hour + 1, 0, 0)
end_full_hour = DateTime.new(d2.year, d2.month, d2.day, d2.hour, 0, 0)

start_full_hour.step(end_full_hour, 1/24.0).each{ |d|
  shadow_info['ShadowTime'] = d
  puts(shadow_info['SunDirection'])
}

See DateTime.

Thanks @Aerilius.
I was wondering if there was some method to find the direction at particular hour so that I do not need to store all the 24 values.

You wanted to get it at each hour. If you just want to get it only at a specific time-point, just set the shadow time to that time-point and get that single sun direction.