Class: Jirarest2Field::DateTimeField
- Defined in:
- lib/jirarest2/field.rb
Overview
A field resembling a DateTime
Instance Attribute Summary
Attributes inherited from Field
#allowed_values, #id, #name, #raw_value, #readonly, #required
Instance Method Summary collapse
-
#parse_value(jvalue) ⇒ Object
Parse the value of this field as sent by the server.
-
#to_j(value = @value) ⇒ Hash
Representation to be used for json and JIRA(tm) JIRA(tm) expects certain format which we try to accomodate here.
-
#value=(content) ⇒ Object
Set the value.
Methods inherited from DateField
Methods inherited from Field
#createmeta, #initialize, #value, #value_allowed?
Constructor Details
This class inherits a constructor from Jirarest2Field::Field
Instance Method Details
#parse_value(jvalue) ⇒ Object
Parse the value of this field as sent by the server
227 228 229 230 |
# File 'lib/jirarest2/field.rb', line 227 def parse_value(jvalue) super @value = DateTime.parse(jvalue) end |
#to_j(value = @value) ⇒ Hash
Representation to be used for json and JIRA(tm) JIRA(tm) expects certain format which we try to accomodate here
235 236 237 238 239 240 241 242 |
# File 'lib/jirarest2/field.rb', line 235 def to_j(value = @value) if value.nil? then super(nil) else strvalue = value.strftime("%FT%T.%L%z") super(strvalue) end end |
#value=(content) ⇒ Object
Set the value
220 221 222 223 |
# File 'lib/jirarest2/field.rb', line 220 def value=(content) value = DateTime.parse(content) @value = value if value_allowed?(value) end |