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

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

Instance Method Summary collapse

Constructor Details

#initialize(uri, &source) ⇒ Gherkin

Returns a new instance of Gherkin.



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

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

Instance Method Details

#buildObject



38
39
40
41
# File 'lib/cucumber/core/gherkin/writer.rb', line 38

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

#comment(line) ⇒ Object



23
24
25
# File 'lib/cucumber/core/gherkin/writer.rb', line 23

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

#comment_linesObject



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

def comment_lines
  @comment_lines ||= []
end

#feature(*args, &source) ⇒ Object



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

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