Class: Flatito::JsonScanner
- Inherits:
-
Object
- Object
- Flatito::JsonScanner
- Defined in:
- lib/flatito/json_scanner.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content) ⇒ JsonScanner
constructor
A new instance of JsonScanner.
- #items ⇒ Object
Constructor Details
#initialize(content) ⇒ JsonScanner
Returns a new instance of JsonScanner.
13 14 15 16 |
# File 'lib/flatito/json_scanner.rb', line 13 def initialize(content) @content = content @line_index = nil end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/flatito/json_scanner.rb', line 11 def content @content end |
Class Method Details
.scan(content) ⇒ Object
7 8 9 |
# File 'lib/flatito/json_scanner.rb', line 7 def self.scan(content) new(content).items end |
Instance Method Details
#items ⇒ Object
18 19 20 21 22 23 |
# File 'lib/flatito/json_scanner.rb', line 18 def items hash = JSON.parse(content) flatten(hash) rescue JSON::ParserError nil end |