Sha256: e9cf84591d7559d137865e22d72d99a82f8d64af2b18de00b37ce1ad0cfefa7d
Contents?: true
Size: 697 Bytes
Versions: 3
Compression:
Stored size: 697 Bytes
Contents
require 'date' class Dexby::Parse TREND_MAP = {0=>:"", 1=>:rising_quickly, 2=>:rising, 3=>:rising_slightly, 4=>:steady, 5=>:falling_slightly, 6=>:falling, 7=>:falling_quickly, 8=>:unknown, 9=>:unavailable} def self.parse(item) date = parse_date(item['WT']) trend = parse_trend(item['Trend']) value = item['Value'] return {trend: trend, date: date, value: value} end def self.parse_trend(value) return TREND_MAP[value] if TREND_MAP.key? value raise ArgumentError end def self.parse_date(value) return DateTime.strptime(value, '/Date(%Q)/').new_offset(DateTime.now.offset) end def self.parse_all(items) return items.map{|i| parse(i)} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dexby-0.1.1 | lib/dexby/parse.rb |
dexby-0.1.0 | lib/dexby/parse.rb |
dexby-0.0.1 | lib/dexby/parse.rb |