Class: Inform::Ephemeral::Link

Inherits:
Object
  • Object
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

Constructor Details

#initialize(properties) ⇒ Link

Returns a new instance of Link.



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

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

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

#modified_atObject

Returns the value of attribute modified_at.



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

def modified_at
  @modified_at
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#toObject

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



57
58
59
# File 'lib/story_teller/inform/ephemeral/link.rb', line 57

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

#after_saveObject



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

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

#before_createObject



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

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

#saveObject



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

def save
  after_save
end

#to_sObject



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

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