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
# File 'lib/cucumber/core/gherkin/writer.rb', line 18

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

Instance Method Details

#buildObject



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

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

#comment(line) ⇒ Object



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

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

#comment_linesObject



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

def comment_lines
  @comment_lines ||= []
end

#feature(*args, &source) ⇒ Object



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

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