Class: Coach4rb::Resource::Entry
- Inherits:
-
Entity
- Object
- Entity
- Coach4rb::Resource::Entry
- Defined in:
- lib/coach4rb/resource/entry.rb,
lib/coach4rb/resource/entry.rb
Constant Summary
- 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)
-
- (Object) comment
Returns the value of attribute comment.
-
- (Object) datecreated
(also: #created)
Returns the value of attribute datecreated.
-
- (Object) datemodified
(also: #modified)
Returns the value of attribute datemodified.
-
- (Object) entrydate
(also: #entry_date)
Returns the value of attribute entrydate.
-
- (Object) entryduration
(also: #entry_duration)
Returns the value of attribute entryduration.
-
- (Object) entrylocation
(also: #entry_location)
Returns the value of attribute entrylocation.
-
- (Object) id
Returns the value of attribute id.
-
- (Object) subscription
Returns the value of attribute subscription.
-
- (Object) uri
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
- (Object) comment
Returns the value of attribute comment
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def comment @comment end |
- (Object) datecreated 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 |
- (Object) datemodified 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 |
- (Object) entrydate 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 |
- (Object) entryduration 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 |
- (Object) entrylocation 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 |
- (Object) id
Returns the value of attribute id
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def id @id end |
- (Object) subscription
Returns the value of attribute subscription
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def subscription @subscription end |
- (Object) uri
Returns the value of attribute uri
7 8 9 |
# File 'lib/coach4rb/resource/entry.rb', line 7 def uri @uri end |
Class Method Details
+ (Object) from_coach(a_hash)
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
- (Object) type
34 35 36 |
# File 'lib/coach4rb/resource/entry.rb', line 34 def type raise 'Not implemented!' end |