Sha256: c7a746e62a3a1571a4fe7468f2b14270de1e7fd55cfcbac6eaab98a0b9bc84a7

Contents?: true

Size: 532 Bytes

Versions: 33

Compression:

Stored size: 532 Bytes

Contents

class Gobstones::ExampleCodeBuilder
  def initialize(code, example, options)
    @code = code
    @example = example
    @options = options
  end

  def build
    return @code unless subject
<<GBS
#{@code}
program {
   #{code_call}
}
GBS
  end

  private

  def code_call
    subject.initial_is_lower? ? "return (#{invocation})" : invocation
  end

  def subject
    @options[:subject]
  end

  def invocation
    "#{subject}(#{arguments})"
  end

  def arguments
    (@example[:preconditions][:arguments] || []).join ','
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
mumuki-gobstones-runner-2.3.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.2.1 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.2.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.1.3 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.1.2 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.1.1 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.1.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.0.1 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.12.1 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-2.0.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.12.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.11.2 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.11.1 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.11.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.10.2 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.10.1 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.10.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.8.0 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.7.5 lib/gobstones/example_code_builder.rb
mumuki-gobstones-runner-1.7.4 lib/gobstones/example_code_builder.rb