Class: Hash2lrtemplate::JSON2lrtemplate
- Inherits:
-
Object
- Object
- Hash2lrtemplate::JSON2lrtemplate
- Includes:
- CallableClass
- Defined in:
- lib/hash2lrtemplate/json2lrtemplate.rb
Overview
Transformations:
-
Transform “keys” to
keys
(remove quotes) -
Transform
[]
to {} -
Transform
:
to = -
Remove leading and ending {}
-
, before closing }
Instance Attribute Summary collapse
-
#json_string ⇒ Object
readonly
Returns the value of attribute json_string.
Instance Method Summary collapse
-
#call ⇒ String
Convert from JSON to
.lrtemplate
format. -
#initialize(json_string) ⇒ JSON2lrtemplate
constructor
A new instance of JSON2lrtemplate.
Constructor Details
#initialize(json_string) ⇒ JSON2lrtemplate
Returns a new instance of JSON2lrtemplate.
16 17 18 19 20 |
# File 'lib/hash2lrtemplate/json2lrtemplate.rb', line 16 def initialize(json_string) raise Hash2lrtemplate::Error, 'Invalid class. Expected class: `String`' unless json_string.is_a?(String) @json_string = json_string end |
Instance Attribute Details
#json_string ⇒ Object (readonly)
Returns the value of attribute json_string.
14 15 16 |
# File 'lib/hash2lrtemplate/json2lrtemplate.rb', line 14 def json_string @json_string end |
Instance Method Details
#call ⇒ String
Convert from JSON to .lrtemplate
format
27 28 29 |
# File 'lib/hash2lrtemplate/json2lrtemplate.rb', line 27 def call convert end |