Class: Specific::Renderer::Text

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/specific/renderer/text.rb

Instance Method Summary collapse

Methods included from Base

included, registered

Constructor Details

#initialize(spec) ⇒ Text

Returns a new instance of Text.



8
9
10
# File 'lib/specific/renderer/text.rb', line 8

def initialize(spec)
  @spec = spec
end

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/specific/renderer/text.rb', line 12

def render
  out = ""

  grouped_features = @spec.features.group_by(&:group)

  grouped_features.each do |group, features|
    group_title =  "Group '#{group.name}'"

    out << group_title + "\n"
    out << "="*group_title.size + "\n"

    features.sort_by(&:id).each do |feature|
      out << ("  [F%0.4d] - %s" % [feature.id, feature.name]) + "\n"
    end
  end

  out
end