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.



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

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

Instance Method Details

#buildObject



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

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

#comment(line) ⇒ Object



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

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

#comment_linesObject



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

def comment_lines
  @comment_lines ||= []
end

#feature(*args, &source) ⇒ Object



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

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