Class: Elemac::Overview
- Inherits:
-
Object
- Object
- Elemac::Overview
- Defined in:
- lib/elemac/overview.rb
Constant Summary collapse
- PROP_CURRENT_HOUR =
62- PROP_CURRENT_MINUTE =
63- PROP_CURRENT_SECOND =
64- PROP_CURRENT_DAY =
371- PROP_CURRENT_MONTH =
370- PROP_CURRENT_YEAR =
369- PROP_CURRENT_DOW =
368- DAY_NIGHT_FLAG =
84- DAY_NIGHT_LIGHT_FLAG =
86- DAY_FLAG =
4- DAY_LIGHT_FLAG =
1- NIGHT_LIGHT_FLAG =
64- OFFSET =
0
Instance Method Summary collapse
- #current_date ⇒ Object
- #current_day ⇒ Object
- #current_day_of_week ⇒ Object
- #current_hour ⇒ Object
- #current_minute ⇒ Object
- #current_month ⇒ Object
- #current_second ⇒ Object
- #current_time ⇒ Object
- #current_year ⇒ Object
- #day ⇒ Object
- #day_light ⇒ Object
- #day_night_flags ⇒ Object
- #day_night_light_flags ⇒ Object
- #get_offset ⇒ Object
-
#initialize(device:) ⇒ Overview
constructor
A new instance of Overview.
- #inspect ⇒ Object
- #night ⇒ Object
- #night_light ⇒ Object
Constructor Details
#initialize(device:) ⇒ Overview
Returns a new instance of Overview.
20 21 22 |
# File 'lib/elemac/overview.rb', line 20 def initialize(device:) @device = device end |
Instance Method Details
#current_date ⇒ Object
43 44 45 |
# File 'lib/elemac/overview.rb', line 43 def current_date Converter.format_date(current_year, current_month, current_day) end |
#current_day ⇒ Object
28 29 30 31 |
# File 'lib/elemac/overview.rb', line 28 def current_day prop = Property.new(offset: get_offset, address: PROP_CURRENT_DAY, type: :char) get_data(prop.to_s).to_i end |
#current_day_of_week ⇒ Object
66 67 68 69 |
# File 'lib/elemac/overview.rb', line 66 def current_day_of_week prop = Property.new(offset: get_offset, address: PROP_CURRENT_DOW, type: :char) get_data(prop.to_s) end |
#current_hour ⇒ Object
47 48 49 50 |
# File 'lib/elemac/overview.rb', line 47 def current_hour prop = Property.new(offset: get_offset, address: PROP_CURRENT_HOUR, type: :char) get_data(prop.to_s).to_i end |
#current_minute ⇒ Object
52 53 54 55 |
# File 'lib/elemac/overview.rb', line 52 def current_minute prop = Property.new(offset: get_offset, address: PROP_CURRENT_MINUTE, type: :char) get_data(prop.to_s).to_i end |
#current_month ⇒ Object
33 34 35 36 |
# File 'lib/elemac/overview.rb', line 33 def current_month prop = Property.new(offset: get_offset, address: PROP_CURRENT_MONTH, type: :char) get_data(prop.to_s).to_i end |
#current_second ⇒ Object
57 58 59 60 |
# File 'lib/elemac/overview.rb', line 57 def current_second prop = Property.new(offset: get_offset, address: PROP_CURRENT_SECOND, type: :char) get_data(prop.to_s).to_i end |
#current_time ⇒ Object
62 63 64 |
# File 'lib/elemac/overview.rb', line 62 def current_time Converter.format_time(current_hour, current_minute, current_second) end |
#current_year ⇒ Object
38 39 40 41 |
# File 'lib/elemac/overview.rb', line 38 def current_year prop = Property.new(offset: get_offset, address: PROP_CURRENT_YEAR, type: :char) 2000 + get_data(prop.to_s).to_i end |
#day ⇒ Object
81 82 83 |
# File 'lib/elemac/overview.rb', line 81 def day day_night_flags & DAY_FLAG != 0 end |
#day_light ⇒ Object
89 90 91 |
# File 'lib/elemac/overview.rb', line 89 def day_light day_night_light_flags & DAY_LIGHT_FLAG != 0 end |
#day_night_flags ⇒ Object
71 72 73 74 |
# File 'lib/elemac/overview.rb', line 71 def day_night_flags prop = Property.new(offset: get_offset, address: DAY_NIGHT_FLAG, type: :char) get_data(prop.to_s) end |
#day_night_light_flags ⇒ Object
76 77 78 79 |
# File 'lib/elemac/overview.rb', line 76 def day_night_light_flags prop = Property.new(offset: get_offset, address: DAY_NIGHT_LIGHT_FLAG, type: :char) get_data(prop.to_s) end |
#get_offset ⇒ Object
24 25 26 |
# File 'lib/elemac/overview.rb', line 24 def get_offset OFFSET end |
#inspect ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/elemac/overview.rb', line 97 def inspect puts "DATE:\t\t#{current_date}" puts "TIME:\t\t#{current_time}" puts "DAY OF WEEK:\t#{current_day_of_week}" puts "D/N FLG:\t#{day_night_flags} (#{day_night_flags.to_s(2)})" puts "D/N LIGHT FLG:\t#{day_night_light_flags} (#{day_night_light_flags.to_s(2)})" puts "IS DAY:\t\t#{day}" puts "IS NIGHT:\t#{night}" puts "DAY LIGHT:\t#{day_light}" puts "NIGHT LIGHT:\t#{night_light}" end |
#night ⇒ Object
85 86 87 |
# File 'lib/elemac/overview.rb', line 85 def night !day end |
#night_light ⇒ Object
93 94 95 |
# File 'lib/elemac/overview.rb', line 93 def night_light day_night_light_flags & NIGHT_LIGHT_FLAG != 0 end |