Class: Inform::Ephemeral::Link
- 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
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #after_save ⇒ Object
- #before_create ⇒ Object
- #init_with(coder) ⇒ Object
-
#initialize(properties) ⇒ Link
constructor
A new instance of Link.
- #to_s ⇒ Object
Methods inherited from Link
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
#from ⇒ Object (readonly)
Returns the value of attribute from.
31 32 33 |
# File 'lib/story_teller/inform/ephemeral/link.rb', line 31 def from @from end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/story_teller/inform/ephemeral/link.rb', line 31 def name @name end |
#to ⇒ Object (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_save ⇒ Object
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_create ⇒ Object
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_s ⇒ Object
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 |