Class: Lightswitch::StateChange

Inherits:
Object
  • Object
show all
Defined in:
lib/lightswitch/schedule_mixins.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state_string, at_time) ⇒ StateChange

Returns a new instance of StateChange.



44
45
46
# File 'lib/lightswitch/schedule_mixins.rb', line 44

def initialize(state_string, at_time)
  @state, @at_time = state_string, at_time
end

Instance Attribute Details

#at_timeObject

Returns the value of attribute at_time.



42
43
44
# File 'lib/lightswitch/schedule_mixins.rb', line 42

def at_time
  @at_time
end

#stateObject

Returns the value of attribute state.



42
43
44
# File 'lib/lightswitch/schedule_mixins.rb', line 42

def state
  @state
end

Instance Method Details

#equal?(other) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/lightswitch/schedule_mixins.rb', line 54

def equal?(other)
  other.is_a? StateChange and (other.state == state and other.at_time == at_time)
end

#to_hObject



48
49
50
# File 'lib/lightswitch/schedule_mixins.rb', line 48

def to_h
  {state: state, at_time: at_time}
end

#to_sObject



52
# File 'lib/lightswitch/schedule_mixins.rb', line 52

def to_s; "State change to #{state} at #{at_time}"; end