Class: Inform::Ephemeral::Link

Inherits:
Link show all
Defined in:
lib/story_teller/inform/ephemeral/link.rb

Overview

The Inform::Ephemeral::Link class

Constant Summary collapse

LinkTemplate =
'%<link_name>s -> %<to_name>s [%<to_identity>s]'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Link

adapter_class, new

Methods included from AdapterClassDelegation

#===, #delegated_adapter_class, #method_missing, #respond_to_missing?

Constructor Details

#initialize(properties) ⇒ Link

Returns a new instance of Link.



33
34
35
36
37
38
# File 'lib/story_teller/inform/ephemeral/link.rb', line 33

def initialize(properties)
  super()
  @name = properties[:name]
  @to = properties[:to]
  @from = properties[:from]
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



31
32
33
# File 'lib/story_teller/inform/ephemeral/link.rb', line 31

def from
  @from
end

#nameObject (readonly)

Returns the value of attribute name.



31
32
33
# File 'lib/story_teller/inform/ephemeral/link.rb', line 31

def name
  @name
end

#toObject (readonly)

Returns the value of attribute to.



31
32
33
# File 'lib/story_teller/inform/ephemeral/link.rb', line 31

def to
  @to
end

Instance Method Details

#<=>(other) ⇒ Object



54
55
56
# File 'lib/story_teller/inform/ephemeral/link.rb', line 54

def <=>(other)
  self.name <=> other.name
end

#after_saveObject



45
46
47
48
# File 'lib/story_teller/inform/ephemeral/link.rb', line 45

def after_save
  super
  self.modified_at = Time.now.utc
end

#before_createObject



40
41
42
43
# File 'lib/story_teller/inform/ephemeral/link.rb', line 40

def before_create
  self.created_at ||= Time.now
  super
end

#init_with(coder) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/story_teller/inform/ephemeral/link.rb', line 58

def init_with(coder)
  LinkMethods.each do |method_name|
    method_symbol = format(MethodWriterTemplate, method_name: method_name).to_sym
    self.send(method_symbol, coder[method_name]) if self.respond_to? method_symbol
  end
  self
end

#to_sObject



50
51
52
# File 'lib/story_teller/inform/ephemeral/link.rb', line 50

def to_s
  format(LinkTemplate, link_name: name, to_name: to.name, to_identity: to.identity)
end