Class: Seinfeld::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/seinfeld.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Entry

Returns a new instance of Entry.



8
9
10
11
# File 'lib/seinfeld.rb', line 8

def initialize(attributes={})
  @attributes = attributes
  @attributes['date'] ||= Date.today
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/seinfeld.rb', line 19

def method_missing(name, *args)
  if attributes[name.to_s]
    return attributes[name.to_s]
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



13
14
15
# File 'lib/seinfeld.rb', line 13

def attributes
  @attributes
end

Instance Method Details

#as_jsonObject



15
16
17
# File 'lib/seinfeld.rb', line 15

def as_json
  attributes
end