Class: Kaede::Program

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channel_for_recorder ⇒ Object

Returns the value of attribute channel_for_recorder

Returns:

  • (Object) —

    the current value of channel_for_recorder



4
5
6
# File 'lib/kaede/program.rb', line 4

def channel_for_recorder
  @channel_for_recorder
end

#channel_for_syoboi ⇒ Object

Returns the value of attribute channel_for_syoboi

Returns:

  • (Object) —

    the current value of channel_for_syoboi



4
5
6
# File 'lib/kaede/program.rb', line 4

def channel_for_syoboi
  @channel_for_syoboi
end

#channel_name ⇒ Object

Returns the value of attribute channel_name

Returns:

  • (Object) —

    the current value of channel_name



4
5
6
# File 'lib/kaede/program.rb', line 4

def channel_name
  @channel_name
end

#comment ⇒ Object

Returns the value of attribute comment

Returns:

  • (Object) —

    the current value of comment



4
5
6
# File 'lib/kaede/program.rb', line 4

def comment
  @comment
end

#count ⇒ Object

Returns the value of attribute count

Returns:

  • (Object) —

    the current value of count



4
5
6
# File 'lib/kaede/program.rb', line 4

def count
  @count
end

#end_time ⇒ Object

Returns the value of attribute end_time

Returns:

  • (Object) —

    the current value of end_time



4
5
6
# File 'lib/kaede/program.rb', line 4

def end_time
  @end_time
end

#pid ⇒ Object

Returns the value of attribute pid

Returns:

  • (Object) —

    the current value of pid



4
5
6
# File 'lib/kaede/program.rb', line 4

def pid
  @pid
end

#start_offset ⇒ Object

Returns the value of attribute start_offset

Returns:

  • (Object) —

    the current value of start_offset



4
5
6
# File 'lib/kaede/program.rb', line 4

def start_offset
  @start_offset
end

#start_time ⇒ Object

Returns the value of attribute start_time

Returns:

  • (Object) —

    the current value of start_time



4
5
6
# File 'lib/kaede/program.rb', line 4

def start_time
  @start_time
end

#subtitle ⇒ Object

Returns the value of attribute subtitle

Returns:

  • (Object) —

    the current value of subtitle



4
5
6
# File 'lib/kaede/program.rb', line 4

def subtitle
  @subtitle
end

#tid ⇒ Object

Returns the value of attribute tid

Returns:

  • (Object) —

    the current value of tid



4
5
6
# File 'lib/kaede/program.rb', line 4

def tid
  @tid
end

#title ⇒ Object

Returns the value of attribute title

Returns:

  • (Object) —

    the current value of title



4
5
6
# File 'lib/kaede/program.rb', line 4

def title
  @title
end

Class Method Details

.from_xml(doc) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kaede/program.rb', line 5

def self.from_xml(doc)
  doc.xpath('//progitem').map do |item|
    prog = self.new
    prog.pid = item['pid'].to_i
    prog.tid = item['tid'].to_i
    prog.start_time = Time.parse(item['sttime'])
    prog.end_time = Time.parse(item['edtime'])
    prog.channel_for_syoboi = item['chid'].to_i
    prog.count = item['count'].to_i
    prog.start_offset = item['stoffset'].to_i # in second
    prog.subtitle = item['subtitle']
    prog.title = item['title']
    prog.comment = item['progcomment']
    prog
  end
end

Instance Method Details

#format_fname ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/kaede/program.rb', line 30

def format_fname
  fname = "#{tid}_#{pid} #{title} ##{count} #{subtitle}#{comment.empty? ? '' : " (#{comment})"} at #{channel_name}"
  fname = fname.gsub('/', '/')
  if fname.bytesize >= 200
    fname = "#{tid}_#{pid} #{title} ##{count} at #{channel_name}"
  end
  fname
end

#formatted_fname ⇒ Object



26
27
28
# File 'lib/kaede/program.rb', line 26

def formatted_fname
  @formatted_fname ||= format_fname
end

#syoboi_url ⇒ Object



22
23
24
# File 'lib/kaede/program.rb', line 22

def syoboi_url
  "http://cal.syoboi.jp/tid/#{tid}##{pid}"
end