class GreenButton::Parser

Attributes

doc[RW]
usage_points[RW]

Public Class Methods

new(doc) click to toggle source
# File lib/greenbutton.rb, line 26
          def initialize(doc)
                  @doc = doc
                  @usage_points = []
                  doc.xpath('//UsagePoint').each do |usage_point|
  @usage_points << UsagePoint.new(usage_point.parent.parent, self)
end
          end

Public Instance Methods

filter_usage_points(params) click to toggle source
# File lib/greenbutton.rb, line 34
def filter_usage_points(params)
  # customer_id, service_kind, title, id, href
  filtered = []
  @usage_points.each do |usage_point|
    params.each_pair do |key, value|
      filtered << usage_point if usage_point.send(key) == value
    end
  end
  filtered
end
get_unique(attr) click to toggle source
# File lib/greenbutton.rb, line 45
          def get_unique(attr)
            #customer_id, service_kind, title
            unique = []
@usage_points.each do |usage_point|
  val = usage_point.send(attr)
  if !unique.include?(val)
    unique << val
  end
end
unique
          end