Class: Elemac::Overview

Inherits:
Object
  • Object
show all
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

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_dateObject



43
44
45
# File 'lib/elemac/overview.rb', line 43

def current_date
  Converter.format_date(current_year, current_month, current_day)
end

#current_dayObject



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_weekObject



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_hourObject



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_minuteObject



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_monthObject



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_secondObject



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_timeObject



62
63
64
# File 'lib/elemac/overview.rb', line 62

def current_time
  Converter.format_time(current_hour, current_minute, current_second)
end

#current_yearObject



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

#dayObject



81
82
83
# File 'lib/elemac/overview.rb', line 81

def day
  day_night_flags & DAY_FLAG != 0
end

#day_lightObject



89
90
91
# File 'lib/elemac/overview.rb', line 89

def day_light
  day_night_light_flags & DAY_LIGHT_FLAG != 0
end

#day_night_flagsObject



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_flagsObject



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_offsetObject



24
25
26
# File 'lib/elemac/overview.rb', line 24

def get_offset
  OFFSET
end

#inspectObject



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

#nightObject



85
86
87
# File 'lib/elemac/overview.rb', line 85

def night
  !day
end

#night_lightObject



93
94
95
# File 'lib/elemac/overview.rb', line 93

def night_light
  day_night_light_flags & NIGHT_LIGHT_FLAG != 0
end