class Snapple::Parser

Constants

FACT_FILENAME

Attributes

facts[R]

Public Class Methods

new() click to toggle source
# File lib/snapple/parser.rb, line 8
def initialize
  @facts = []
end

Public Instance Methods

parse() click to toggle source
# 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

Private Instance Methods

load_file() click to toggle source
# File lib/snapple/parser.rb, line 27
def load_file
  @file ||= File.read(File.expand_path("../../../#{FACT_FILENAME}", __FILE__))
end
parse_json() click to toggle source
# File lib/snapple/parser.rb, line 23
def parse_json
  @json ||= JSON.parse(load_file)
end