Class: Cucumber::Core::Gherkin::Writer::Gherkin

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/gherkin/writer/gherkin.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, &source) ⇒ Gherkin

Returns a new instance of Gherkin.



11
12
13
14
# File 'lib/cucumber/core/gherkin/writer/gherkin.rb', line 11

def initialize(uri, &source)
  @uri = uri
  @source = source
end

Instance Method Details

#buildObject



31
32
33
34
# File 'lib/cucumber/core/gherkin/writer/gherkin.rb', line 31

def build
  instance_exec(&@source)
  Document.new(@uri, @feature.build.join("\n"))
end

#comment(line) ⇒ Object



16
17
18
# File 'lib/cucumber/core/gherkin/writer/gherkin.rb', line 16

def comment(line)
  comment_lines << "# #{line}"
end

#comment_linesObject



20
21
22
# File 'lib/cucumber/core/gherkin/writer/gherkin.rb', line 20

def comment_lines
  @comment_lines ||= []
end

#feature(*args, &source) ⇒ Object



24
25
26
27
28
29
# File 'lib/cucumber/core/gherkin/writer/gherkin.rb', line 24

def feature(*args, &source)
  @feature = Feature.new(comment_lines, *args).tap do |builder|
    builder.instance_exec(&source) if source
  end
  self
end