Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: afcce7c825
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (41 sloc) 1.024 kb
class HarvestEntry
def initialize(parsed)
@hash = parsed
end
def id
self.method_missing(:id)
end
def empty?
if @hash["type"] == "array" && @hash["content"] == "\n"
true
else
false
end
end
def expense?
begin
self.expense_category_id
true
rescue
false
end
end
def method_missing(method, *args)
method = method.to_s.gsub("_", "-").to_sym
if @hash.has_key?(method.to_s.singularize)
entry = @hash[method.to_s.singularize]
if method.to_s.pluralize == method.to_s && entry.class == Array
return entry.collect {|e| HarvestEntry.new(e)}
else
return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
return entry[0]["content"]
end
elsif @hash.has_key?(method.to_s)
entry = @hash[method.to_s]
return entry[0] unless entry[0].class == Hash && entry[0].has_key?("content")
return entry[0]["content"]
else
super
end
end
end
Jump to Line
Something went wrong with that request. Please try again.