class AmazonOrder::Parsers::Base
Attributes
fetched_at[RW]
Public Class Methods
new(node, options = {})
click to toggle source
# File lib/amazon_order/parsers/base.rb, line 6 def initialize(node, options = {}) @node = node @fetched_at = options[:fetched_at] @containing_object = options[:containing_object] end
Public Instance Methods
get_original_image_url(url)
click to toggle source
# File lib/amazon_order/parsers/base.rb, line 38 def get_original_image_url(url) parts = url.split('/') (parts[0..-2] + [parts.last.split('.').values_at(0,-1).join('.')]).join('/') end
inspect()
click to toggle source
# File lib/amazon_order/parsers/base.rb, line 12 def inspect "#<#{self.class.name}:#{self.object_id} #{self.to_hash}>" end
parse_date(date_text)
click to toggle source
# File lib/amazon_order/parsers/base.rb, line 29 def parse_date(date_text) begin Date.parse(date_text) rescue ArgumentError => e m = date_text.match(/\A(?<year>\d{4})年(?<month>\d{1,2})月(?<day>\d{1,2})日\z/) Date.new(m[:year].to_i, m[:month].to_i, m[:day].to_i) end end
to_hash() { |hash| ... }
click to toggle source
# File lib/amazon_order/parsers/base.rb, line 16 def to_hash hash = {} self.class::ATTRIBUTES.each do |f| hash[f] = send(f) end yield(hash) if block_given? hash end
values()
click to toggle source
# File lib/amazon_order/parsers/base.rb, line 25 def values self.class::ATTRIBUTES.map{|a| send(a) } end