class MethodBuilder::ParserMethodProxy
Public Instance Methods
convert_time(left_time)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 40 def convert_time(left_time) days = ((left_time / (60 * 60 * 24))).to_i hours = ((left_time / (60 * 60)) % 24).to_i minutes = ((left_time / 60) % 60).to_i "#{days}天#{hours}小時#{minutes}分鐘" end
get_string(elements)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 32 def get_string(elements) elements.first.text.strip end
insert_parser(inserted_class)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 7 def insert_parser(inserted_class) @parser_class = "CrowdFundingParser::Parser::#{inserted_class}".constantize @parser = @parser_class.new end
method_missing(m, *args, &block)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 28 def method_missing(m, *args, &block) "" end
money_string(money)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 36 def money_string(money) money.gsub("$","").gsub(",", "").gsub("NT", "") end
set_method(method_name, &block)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 16 def set_method(method_name, &block) @parser_class.send(:define_method, method_name) do |arg| begin block.call(arg) rescue Exception => e puts "Error #{e.message}" puts e.backtrace.first "" end end end
set_variable(&block)
click to toggle source
# File lib/crowd_funding_parser/method_builder.rb, line 12 def set_variable(&block) block.call end