Class: RubyRest::Atom::DateProperty

Inherits:
SimpleProperty show all
Defined in:
lib/rubyrest/atom.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SimpleProperty

#bind, #format, #initialize, #object_value, #parse, #tag, #xml_value

Constructor Details

This class inherits a constructor from RubyRest::Atom::SimpleProperty

Class Method Details

.format_date(date) ⇒ Object



152
153
154
155
# File 'lib/rubyrest/atom.rb', line 152

def self.format_date( date )
  date = Time.now if !date
  date.strftime( ATOM_DATE_FORMAT )
end

Instance Method Details

#date2string(date) ⇒ Object



157
158
159
# File 'lib/rubyrest/atom.rb', line 157

def date2string( date )
  self.class.format_date( date )
end

#string2date(date) ⇒ Object



161
162
163
# File 'lib/rubyrest/atom.rb', line 161

def string2date( date )
  Date.strptime( value, ATOM_DATE_FORMAT )
end

#value_from_model(options, object) ⇒ Object



165
166
167
# File 'lib/rubyrest/atom.rb', line 165

def value_from_model( options, object )
  date2string( object_value( object, options ) )
end

#value_from_xml(options, xml) ⇒ Object



169
170
171
# File 'lib/rubyrest/atom.rb', line 169

def value_from_xml( options, xml )
  string2date( xml_value( xml, options ) )
end