class Elemac::Overview

Constants

DAY_FLAG
DAY_LIGHT_FLAG
DAY_NIGHT_FLAG
DAY_NIGHT_LIGHT_FLAG
NIGHT_LIGHT_FLAG
OFFSET
PROP_CURRENT_DAY
PROP_CURRENT_DOW
PROP_CURRENT_HOUR
PROP_CURRENT_MINUTE
PROP_CURRENT_MONTH
PROP_CURRENT_SECOND
PROP_CURRENT_YEAR

Public Class Methods

new(device:) click to toggle source
# File lib/elemac/overview.rb, line 20
def initialize(device:)
        @device = device
end

Public Instance Methods

current_date() click to toggle source
# File lib/elemac/overview.rb, line 43
def current_date
        Converter.format_date(current_year, current_month, current_day)
end
current_day() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/elemac/overview.rb, line 62
def current_time
        Converter.format_time(current_hour, current_minute, current_second)
end
current_year() click to toggle source
# 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() click to toggle source
# File lib/elemac/overview.rb, line 81
def day
        day_night_flags & DAY_FLAG != 0
end
day_light() click to toggle source
# File lib/elemac/overview.rb, line 89
def day_light
        day_night_light_flags & DAY_LIGHT_FLAG != 0
end
day_night_flags() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/elemac/overview.rb, line 24
def get_offset
        OFFSET
end
inspect() click to toggle source
# 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() click to toggle source
# File lib/elemac/overview.rb, line 85
def night
        !day
end
night_light() click to toggle source
# File lib/elemac/overview.rb, line 93
def night_light
        day_night_light_flags & NIGHT_LIGHT_FLAG != 0
end

Private Instance Methods

get_data(address) click to toggle source
# File lib/elemac/overview.rb, line 110
def get_data(address)
        @device.request_data(address)
end