Class: Syobocalite::Program

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • pid (Integer) (defaults to: nil)
  • tid (Integer) (defaults to: nil)
  • st_time (ActiveSupport::TimeWithZone) (defaults to: nil)
  • ed_time (ActiveSupport::TimeWithZone) (defaults to: nil)
  • ch_name (String) (defaults to: nil)
  • ch_id (Integer) (defaults to: nil)
  • count (Integer) (defaults to: nil)
  • st_offset (Integer) (defaults to: nil)
  • sub_title (String) (defaults to: nil)
  • title (String) (defaults to: nil)
  • prog_comment (String) (defaults to: nil)


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_idInteger

Returns:

  • (Integer)


25
26
27
# File 'lib/syobocalite/program.rb', line 25

def ch_id
  @ch_id
end

#ch_nameString

Returns:

  • (String)


21
22
23
# File 'lib/syobocalite/program.rb', line 21

def ch_name
  @ch_name
end

#countInteger Also known as: story_number

Returns:

  • (Integer)


29
30
31
# File 'lib/syobocalite/program.rb', line 29

def count
  @count
end

#ed_timeActiveSupport::TimeWithZone

Returns:

  • (ActiveSupport::TimeWithZone)


17
18
19
# File 'lib/syobocalite/program.rb', line 17

def ed_time
  @ed_time
end

#pidInteger

Returns:

  • (Integer)


5
6
7
# File 'lib/syobocalite/program.rb', line 5

def pid
  @pid
end

#prog_commentString

Returns:

  • (String)


45
46
47
# File 'lib/syobocalite/program.rb', line 45

def prog_comment
  @prog_comment
end

#st_offsetInteger

Returns:

  • (Integer)


33
34
35
# File 'lib/syobocalite/program.rb', line 33

def st_offset
  @st_offset
end

#st_timeActiveSupport::TimeWithZone

Returns:

  • (ActiveSupport::TimeWithZone)


13
14
15
# File 'lib/syobocalite/program.rb', line 13

def st_time
  @st_time
end

#sub_titleString

Returns:

  • (String)


37
38
39
# File 'lib/syobocalite/program.rb', line 37

def sub_title
  @sub_title
end

#tidInteger

Returns:

  • (Integer)


9
10
11
# File 'lib/syobocalite/program.rb', line 9

def tid
  @tid
end

#titleString

Returns:

  • (String)


41
42
43
# File 'lib/syobocalite/program.rb', line 41

def title
  @title
end

Class Method Details

.from_prog_item(attrs = {}) ⇒ Syobocalite::Program

Parameters:

  • attrs (Hash) (defaults to: {})

Returns:



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

Returns:

  • (Boolean)

See Also:



100
101
102
# File 'lib/syobocalite/program.rb', line 100

def final?
  flag & 0x04 != 0
end

#flagInteger

Get program’s flag

Returns:

  • (Integer)

See Also:



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

Returns:

  • (Boolean)

See Also:



93
94
95
# File 'lib/syobocalite/program.rb', line 93

def new?
  flag & 0x02 != 0
end

#re_air?Boolean

Whether re-air program

Returns:

  • (Boolean)

See Also:



107
108
109
# File 'lib/syobocalite/program.rb', line 107

def re_air?
  flag & 0x08 != 0
end

#remark?Boolean

Whether contains remark

Returns:

  • (Boolean)

See Also:



86
87
88
# File 'lib/syobocalite/program.rb', line 86

def remark?
  flag & 0x01 != 0
end