Class: Syobocalite::Program
- Inherits:
-
Object
- Object
- Syobocalite::Program
- Defined in:
- lib/syobocalite/program.rb
Instance Attribute Summary collapse
- #ch_id ⇒ Integer
- #ch_name ⇒ String
- #count ⇒ Integer (also: #story_number)
- #ed_time ⇒ ActiveSupport::TimeWithZone
- #pid ⇒ Integer
- #prog_comment ⇒ String
- #st_offset ⇒ Integer
- #st_time ⇒ ActiveSupport::TimeWithZone
- #sub_title ⇒ String
- #tid ⇒ Integer
- #title ⇒ String
Class Method Summary collapse
Instance Method Summary collapse
-
#final? ⇒ Boolean
Whether final program.
-
#flag ⇒ Integer
Get program’s flag.
-
#initialize(pid: nil, tid: nil, st_time: nil, ed_time: nil, ch_name: nil, ch_id: nil, count: nil, st_offset: nil, sub_title: nil, title: nil, prog_comment: nil) ⇒ Program
constructor
A new instance of Program.
-
#new? ⇒ Boolean
Whether new program.
-
#re_air? ⇒ Boolean
Whether re-air program.
-
#remark? ⇒ Boolean
Whether contains remark.
Constructor Details
#initialize(pid: nil, tid: nil, st_time: nil, ed_time: nil, ch_name: nil, ch_id: nil, count: nil, st_offset: nil, sub_title: nil, title: nil, prog_comment: nil) ⇒ Program
Returns a new instance of Program.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/syobocalite/program.rb', line 58 def initialize(pid: nil, tid: nil, st_time: nil, ed_time: nil, ch_name: nil, ch_id: nil, count: nil, st_offset: nil, sub_title: nil, title: nil, prog_comment: nil) @pid = pid @tid = tid @st_time = st_time @ed_time = ed_time @ch_name = ch_name @ch_id = ch_id @count = count @st_offset = st_offset @sub_title = sub_title @title = title @prog_comment = prog_comment end |
Instance Attribute Details
#ch_id ⇒ Integer
25 26 27 |
# File 'lib/syobocalite/program.rb', line 25 def ch_id @ch_id end |
#ch_name ⇒ String
21 22 23 |
# File 'lib/syobocalite/program.rb', line 21 def ch_name @ch_name end |
#count ⇒ Integer Also known as: story_number
29 30 31 |
# File 'lib/syobocalite/program.rb', line 29 def count @count end |
#ed_time ⇒ ActiveSupport::TimeWithZone
17 18 19 |
# File 'lib/syobocalite/program.rb', line 17 def ed_time @ed_time end |
#pid ⇒ Integer
5 6 7 |
# File 'lib/syobocalite/program.rb', line 5 def pid @pid end |
#prog_comment ⇒ String
45 46 47 |
# File 'lib/syobocalite/program.rb', line 45 def prog_comment @prog_comment end |
#st_offset ⇒ Integer
33 34 35 |
# File 'lib/syobocalite/program.rb', line 33 def st_offset @st_offset end |
#st_time ⇒ ActiveSupport::TimeWithZone
13 14 15 |
# File 'lib/syobocalite/program.rb', line 13 def st_time @st_time end |
#sub_title ⇒ String
37 38 39 |
# File 'lib/syobocalite/program.rb', line 37 def sub_title @sub_title end |
#tid ⇒ Integer
9 10 11 |
# File 'lib/syobocalite/program.rb', line 9 def tid @tid end |
#title ⇒ String
41 42 43 |
# File 'lib/syobocalite/program.rb', line 41 def title @title end |
Class Method Details
.from_prog_item(attrs = {}) ⇒ Syobocalite::Program
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/syobocalite/program.rb', line 114 def self.from_prog_item(attrs = {}) Syobocalite::Program.new( pid: attrs["PID"]&.to_i, tid: attrs["TID"]&.to_i, st_time: to_time(attrs["StTime"]), ed_time: to_time(attrs["EdTime"]), ch_name: attrs["ChName"], ch_id: attrs["ChID"]&.to_i, count: attrs["Count"]&.to_i, st_offset: attrs["StOffset"]&.to_i, sub_title: sanitize_text(attrs["SubTitle"]), title: sanitize_text(attrs["Title"]), prog_comment: attrs["ProgComment"]&.gsub(/^!/, ""), ) end |
Instance Method Details
#final? ⇒ Boolean
Whether final program
100 101 102 |
# File 'lib/syobocalite/program.rb', line 100 def final? flag & 0x04 != 0 end |
#flag ⇒ Integer
Get program’s flag
79 80 81 |
# File 'lib/syobocalite/program.rb', line 79 def flag @flag ||= Syobocalite::DbClient.new.get_program_flag(tid: tid, pid: pid) end |
#new? ⇒ Boolean
Whether new program
93 94 95 |
# File 'lib/syobocalite/program.rb', line 93 def new? flag & 0x02 != 0 end |
#re_air? ⇒ Boolean
Whether re-air program
107 108 109 |
# File 'lib/syobocalite/program.rb', line 107 def re_air? flag & 0x08 != 0 end |
#remark? ⇒ Boolean
Whether contains remark
86 87 88 |
# File 'lib/syobocalite/program.rb', line 86 def remark? flag & 0x01 != 0 end |