Class: Csquery::FieldValue
- Inherits:
-
Object
- Object
- Csquery::FieldValue
- Defined in:
- lib/csquery/field_value.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value:, name: nil) ⇒ FieldValue
constructor
A new instance of FieldValue.
- #to_s ⇒ Object
- #to_value ⇒ Object
Constructor Details
#initialize(value:, name: nil) ⇒ FieldValue
Returns a new instance of FieldValue.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/csquery/field_value.rb', line 5 def initialize(value:, name: nil) value = value[0] if value.is_a?(Array) and value[0].is_a?(Hash) if value.is_a?(Hash) @name = value.keys[0] @value = Structured.format_value(value.values[0]) else @name = name @value = Structured.format_value(value) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/csquery/field_value.rb', line 3 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/csquery/field_value.rb', line 3 def value @value end |
Instance Method Details
#to_s ⇒ Object
23 24 25 |
# File 'lib/csquery/field_value.rb', line 23 def to_s to_value end |
#to_value ⇒ Object
17 18 19 20 21 |
# File 'lib/csquery/field_value.rb', line 17 def to_value return "#{@name}:#{@value}" if @name @value end |