Class: Urbit::Fact::BaseFact
- Inherits:
-
Object
- Object
- Urbit::Fact::BaseFact
show all
- Defined in:
- lib/urbit/fact/base_fact.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(channel:, event:) ⇒ BaseFact
Returns a new instance of BaseFact.
8
9
10
11
12
|
# File 'lib/urbit/fact/base_fact.rb', line 8
def initialize(channel:, event:)
@channel = channel
@data = event.data
@type = event.type
end
|
Instance Attribute Details
#ack ⇒ Object
Returns the value of attribute ack.
6
7
8
|
# File 'lib/urbit/fact/base_fact.rb', line 6
def ack
@ack
end
|
#channel ⇒ Object
Returns the value of attribute channel.
6
7
8
|
# File 'lib/urbit/fact/base_fact.rb', line 6
def channel
@channel
end
|
#data ⇒ Object
Returns the value of attribute data.
6
7
8
|
# File 'lib/urbit/fact/base_fact.rb', line 6
def data
@data
end
|
#type ⇒ Object
Returns the value of attribute type.
6
7
8
|
# File 'lib/urbit/fact/base_fact.rb', line 6
def type
@type
end
|
Instance Method Details
#add_ack(ack:) ⇒ Object
14
15
16
|
# File 'lib/urbit/fact/base_fact.rb', line 14
def add_ack(ack:)
@ack = :ack
end
|
#contents ⇒ Object
18
19
20
|
# File 'lib/urbit/fact/base_fact.rb', line 18
def contents
JSON.parse(@data)
end
|
#create_parser ⇒ Object
22
23
24
|
# File 'lib/urbit/fact/base_fact.rb', line 22
def create_parser
nil
end
|
#for_this_ship? ⇒ Boolean
26
27
28
|
# File 'lib/urbit/fact/base_fact.rb', line 26
def for_this_ship?
self.ship == @channel.ship
end
|
#graph_update? ⇒ Boolean
30
31
32
|
# File 'lib/urbit/fact/base_fact.rb', line 30
def graph_update?
false
end
|
#is_acknowledged? ⇒ Boolean
34
35
36
|
# File 'lib/urbit/fact/base_fact.rb', line 34
def is_acknowledged?
!@ack.nil?
end
|
#raw_json ⇒ Object
38
39
40
|
# File 'lib/urbit/fact/base_fact.rb', line 38
def raw_json
nil
end
|
#ship ⇒ Object
42
43
44
|
# File 'lib/urbit/fact/base_fact.rb', line 42
def ship
@channel.ship
end
|
#to_h ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/urbit/fact/base_fact.rb', line 46
def to_h
{
ship: self.ship.to_h,
acknowleged: self.is_acknowledged?,
is_graph_update: self.graph_update?
}
end
|
#to_s ⇒ Object
54
55
56
|
# File 'lib/urbit/fact/base_fact.rb', line 54
def to_s
"a #{self.class.name}(#{self.to_h})"
end
|