Class: SyoboiCalendar::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/syoboi_calendar/program.rb

Constant Summary collapse

EXT_PARAM_MAP =

(1) :method_name => “NameInSyoboiCalendarResponse” (2) :method_name => [“NameInSyoboiCalendarResponse”, callback]

{
  :channel_epg_url => "ChEPGURL",
  :channel_id      => "ChID",
  :comment         => "Comment",
  :config_flag     => "ConfFlag",
  :count           => "Count",
  :end_time        => ["EdTime", proc { |val| Time.at(val.to_i) }],
  :start_time      => ["StTime", proc { |val| Time.at(val.to_i) }],
  :subtitle        => "SubTitle",
  :subtitle2       => "SubTitle2"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Program

NOTICE: @blob is empty hash at first For example,

If self.start_time is called,
then update_detail is called automatically,
and @blob is updated to fill up @blob[:start_time]


40
41
42
43
44
45
46
# File 'lib/syoboi_calendar/program.rb', line 40

def initialize(args)
  @pid          = args[:pid]
  @tid          = args[:tid]
  @name         = args[:name]
  @channel_name = args[:channel_name]
  @blob         = {}
end

Instance Attribute Details

#channel_nameObject (readonly)

Returns the value of attribute channel_name.



3
4
5
# File 'lib/syoboi_calendar/program.rb', line 3

def channel_name
  @channel_name
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/syoboi_calendar/program.rb', line 3

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.



3
4
5
# File 'lib/syoboi_calendar/program.rb', line 3

def pid
  @pid
end

#tidObject (readonly)

Returns the value of attribute tid.



3
4
5
# File 'lib/syoboi_calendar/program.rb', line 3

def tid
  @tid
end

Instance Method Details

#saisoku?Boolean

SAISOKU means “the most earliest broadcasting in the World”

Returns:

  • (Boolean)


49
50
51
# File 'lib/syoboi_calendar/program.rb', line 49

def saisoku?
  !!title.first_channel.match(channel_name)
end

#titleObject



65
66
67
# File 'lib/syoboi_calendar/program.rb', line 65

def title
  @title ||= Title.new(:tid => @tid)
end

#update_detailObject

update params from detail data



54
55
56
57
58
59
60
61
62
63
# File 'lib/syoboi_calendar/program.rb', line 54

def update_detail
  hash = get_detail
  EXT_PARAM_MAP.each do |k, v|
    if v.kind_of?(Array)
      @blob[k] = v[1].call(hash[v[0]])
    else
      @blob[k] = hash[v]
    end
  end
end