Class: SyoboiCalendar::Comment

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

Constant Summary collapse

PATTERN_SPLITTING_SECTIONS =
/\n{1,2}(?=\*(?!\*))/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Comment

Returns a new instance of Comment.

Parameters:

  • source (String)


9
10
11
# File 'lib/syoboi_calendar/comment.rb', line 9

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceString (readonly)

Returns:

  • (String)


6
7
8
# File 'lib/syoboi_calendar/comment.rb', line 6

def source
  @source
end

Instance Method Details

#castsArray<SyoboiCalendar::Personality>

Returns:



14
15
16
17
18
19
20
# File 'lib/syoboi_calendar/comment.rb', line 14

def casts
  if comment_section = comment_sections.find(&:about_casts?)
    comment_section.personalities
  else
    []
  end
end

#comment_sectionsArray<SyoboiCalendar::CommentSection>

Returns:



23
24
25
26
27
# File 'lib/syoboi_calendar/comment.rb', line 23

def comment_sections
  source.split(PATTERN_SPLITTING_SECTIONS).map do |comment_section_source|
    ::SyoboiCalendar::CommentSection.new(comment_section_source)
  end
end

#songs_endingArray<SyoboiCalendar::Song>

Returns:



30
31
32
33
34
# File 'lib/syoboi_calendar/comment.rb', line 30

def songs_ending
  comment_sections.select(&:about_song_ending?).map do |comment_section|
    ::SyoboiCalendar::Song.new(comment_section.song_attributes)
  end
end

#songs_insertedArray<SyoboiCalendar::Song>

Returns:



37
38
39
40
41
# File 'lib/syoboi_calendar/comment.rb', line 37

def songs_inserted
  comment_sections.select(&:about_song_inserted?).map do |comment_section|
    ::SyoboiCalendar::Song.new(comment_section.song_attributes)
  end
end

#songs_openingArray<SyoboiCalendar::Song>

Returns:



44
45
46
47
48
# File 'lib/syoboi_calendar/comment.rb', line 44

def songs_opening
  comment_sections.select(&:about_song_opening?).map do |comment_section|
    ::SyoboiCalendar::Song.new(comment_section.song_attributes)
  end
end

#songs_themeArray<SyoboiCalendar::Song>

Returns:



51
52
53
54
55
# File 'lib/syoboi_calendar/comment.rb', line 51

def songs_theme
  comment_sections.select(&:about_song_theme?).map do |comment_section|
    ::SyoboiCalendar::Song.new(comment_section.song_attributes)
  end
end

#staffsArray<SyoboiCalendar::Personality>

Returns:



58
59
60
61
62
63
64
# File 'lib/syoboi_calendar/comment.rb', line 58

def staffs
  if comment_section = comment_sections.find(&:about_staffs?)
    comment_section.personalities
  else
    []
  end
end