Class: StandupMD::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/standup_md/section.rb

Overview

A named section of a standup entry, such as current, previous, impediments, or notes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, tasks = []) ⇒ Section

Constructs an instance of StandupMD::Section.

Parameters:

  • type (Symbol, String)
  • tasks (Array<String, StandupMD::Task>) (defaults to: [])


27
28
29
30
# File 'lib/standup_md/section.rb', line 27

def initialize(type, tasks = [])
  @type = type.to_sym
  @tasks = tasks.map { |task| build_task(task) }
end

Instance Attribute Details

#tasksArray<StandupMD::Task> (readonly)

Tasks for the section.

Returns:



20
21
22
# File 'lib/standup_md/section.rb', line 20

def tasks
  @tasks
end

#typeSymbol (readonly)

The semantic section type.

Returns:

  • (Symbol)


14
15
16
# File 'lib/standup_md/section.rb', line 14

def type
  @type
end

Instance Method Details

#<<(task) ⇒ Array<StandupMD::Task>

Adds a task to the section.

Parameters:

Returns:



38
39
40
# File 'lib/standup_md/section.rb', line 38

def <<(task)
  tasks << build_task(task)
end

#empty?Boolean

Is the section empty?

Returns:

  • (Boolean)


46
47
48
# File 'lib/standup_md/section.rb', line 46

def empty?
  tasks.empty?
end

#to_markdownArray<String>

The section rendered as markdown lines.

Returns:

  • (Array<String>)


62
63
64
65
66
67
# File 'lib/standup_md/section.rb', line 62

def to_markdown
  [
    "#" * StandupMD.config.file.sub_header_depth + " " + to_s,
    *tasks.map(&:to_markdown)
  ]
end

#to_sString

The configured section heading.

Returns:

  • (String)


54
55
56
# File 'lib/standup_md/section.rb', line 54

def to_s
  StandupMD.config.file.public_send("#{type}_header")
end