Class: JSONx
- Inherits:
-
Object
- Object
- JSONx
- Defined in:
- lib/jsonx.rb
Instance Attribute Summary collapse
-
#to_json ⇒ Object
readonly
Returns the value of attribute to_json.
-
#to_s ⇒ Object
(also: #to_jsonx, #to_xml)
readonly
Returns the value of attribute to_s.
Instance Method Summary collapse
-
#initialize(obj) ⇒ JSONx
constructor
A new instance of JSONx.
Constructor Details
#initialize(obj) ⇒ JSONx
Returns a new instance of JSONx.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jsonx.rb', line 13 def initialize(obj) if obj.is_a?(String) then if obj.lstrip[0] == '<' then jsonx_to_json obj else json_to_jsonx JSON.parse(obj) end else json_to_jsonx obj # transform the hash end end |
Instance Attribute Details
#to_json ⇒ Object (readonly)
Returns the value of attribute to_json.
11 12 13 |
# File 'lib/jsonx.rb', line 11 def to_json @to_json end |
#to_s ⇒ Object (readonly) Also known as: to_jsonx, to_xml
Returns the value of attribute to_s.
11 12 13 |
# File 'lib/jsonx.rb', line 11 def to_s @to_s end |