Class: Hope::Statement

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/hope/statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ep_statement) ⇒ Statement

Returns a new instance of Statement.



45
46
47
# File 'lib/hope/statement.rb', line 45

def initialize ep_statement
  @ep_statement = ep_statement
end

Instance Attribute Details

#ep_statementObject (readonly)

Returns the value of attribute ep_statement.



15
16
17
# File 'lib/hope/statement.rb', line 15

def ep_statement
  @ep_statement
end

Instance Method Details

#serializable_hashObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/hope/statement.rb', line 53

def serializable_hash
  {
    :id           => name,
    :name         => name,
    :text         => text,
    :updated_at   => updated_at,
    :state        => state.to_s,
    :is_pattern   => pattern?,
    :event_type   => event_type.getName,
    :is_destroyed => destroyed?,
    :listeners    => get_listeners.map { |l| l.serializable_hash  }
  }
end

#to_jsonObject



67
68
69
# File 'lib/hope/statement.rb', line 67

def to_json
  serializable_hash.to_json
end

#to_sObject



41
42
43
# File 'lib/hope/statement.rb', line 41

def to_s
  "[#{name}:#{event_type}] (#{state}) : #{text}"
end

#updated_atObject



49
50
51
# File 'lib/hope/statement.rb', line 49

def updated_at
  Time.at(@ep_statement.getTimeLastStateChange / 1000)
end