Class: Snapple::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/snapple/parser.rb

Constant Summary collapse

FACT_FILENAME =
'all_facts.json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



8
9
10
# File 'lib/snapple/parser.rb', line 8

def initialize
  @facts = []
end

Instance Attribute Details

#factsObject (readonly)

Returns the value of attribute facts.



6
7
8
# File 'lib/snapple/parser.rb', line 6

def facts
  @facts
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
19
# File 'lib/snapple/parser.rb', line 12

def parse
  json = parse_json
  json.each_value do |v|
    @facts << Snapple::Fact.new(v['n'], v['d'], v['c'])
  end

  @facts
end