Class: Coach4rb::Resource::Entry
- Defined in:
- lib/coach4rb/resource/entry.rb,
lib/coach4rb/resource/entry.rb
Constant Summary collapse
- CLASS =
lookup table which associates the types to the correct classes.
{ # :type => Class :entryrunning => Running, :entrysoccer => Soccer, :entryboxing => Boxing, :entrycycling => Cycling }
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#datecreated ⇒ Object
(also: #created)
Returns the value of attribute datecreated.
-
#datemodified ⇒ Object
(also: #modified)
Returns the value of attribute datemodified.
-
#entrydate ⇒ Object
(also: #entry_date)
Returns the value of attribute entrydate.
-
#entryduration ⇒ Object
(also: #entry_duration)
Returns the value of attribute entryduration.
-
#entrylocation ⇒ Object
(also: #entry_location)
Returns the value of attribute entrylocation.
-
#id ⇒ Object
Returns the value of attribute id.
-
#subscription ⇒ Object
Returns the value of attribute subscription.
-
#uri ⇒ Object
Returns the value of attribute uri.
Attributes inherited from Entity
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Entity
Methods included from Mixin::AsHash
Methods included from Mixin::Iterable
Methods included from Mixin::AutoConstructor
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def comment @comment end |
#datecreated ⇒ Object Also known as: created
Returns the value of attribute datecreated.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def datecreated @datecreated end |
#datemodified ⇒ Object Also known as: modified
Returns the value of attribute datemodified.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def datemodified @datemodified end |
#entrydate ⇒ Object Also known as: entry_date
Returns the value of attribute entrydate.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def entrydate @entrydate end |
#entryduration ⇒ Object Also known as: entry_duration
Returns the value of attribute entryduration.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def entryduration @entryduration end |
#entrylocation ⇒ Object Also known as: entry_location
Returns the value of attribute entrylocation.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def entrylocation @entrylocation end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def id @id end |
#subscription ⇒ Object
Returns the value of attribute subscription.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def subscription @subscription end |
#uri ⇒ Object
Returns the value of attribute uri.
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def uri @uri end |
Class Method Details
.from_coach(a_hash) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/coach4rb/resource/entry.rb', line 19 def self.from_coach(a_hash) entry_type = get_type(a_hash) raise 'Error: Entry type not supported!' unless CLASS.keys.include?(entry_type) entry = a_hash[entry_type].dup entry[:datecreated] = Time.at(entry[:datecreated]/1000).to_datetime if entry[:datecreated] entry[:datemodified] = Time.at(entry[:datemodified]/1000).to_datetime if entry[:datemodified] entry[:subscription] = Resource::Subscription.from_coach entry[:subscription] if entry[:subscription] entry[:links] ||= [] klass = CLASS[entry_type] # pick the right class to create the entry klass.new(entry) end |
Instance Method Details
#type ⇒ Object
34 35 36 |
# File 'lib/coach4rb/resource/entry.rb', line 34 def type raise 'Not implemented!' end |