lib/nowtv/client.rb in nowtv-0.0.3 vs lib/nowtv/client.rb in nowtv-0.0.4

- old
+ new

@@ -26,18 +26,23 @@ programs.map do |program| info = program["ProgramInformation"] { station: half_width(program["stationDispName"]), + channel_id: channel_id(program["additionalDisplayChannel"]), title: half_width(info["programTitle"]), start_time: parse_datetime(info["startDateTime"]), end_time: parse_datetime(info["endDateTime"]) } - end + end.sort_by { |program| program[:channel_id] } end def half_width(str) NKF.nkf("-wZ0", str).gsub(" ", " ") + end + + def channel_id(display_channel) + half_width(display_channel).scan(/\d+/).first.to_i end def parse_datetime(datetime) date, time = datetime.split(" ") hour, minute = time.split(":").map(&:to_i)