Module: Docs::ExampleHelper

Included in:
ERBEnvironment, Project, Spec
Defined in:
lib/docs/example/helper.rb

Instance Method Summary collapse

Instance Method Details

#example(source_or_output, name) ⇒ Object

Raises:

  • (ArgumentError)

10
11
12
13
# File 'lib/docs/example/helper.rb', line 10

def example(source_or_output, name)
  raise ArgumentError, "Must specify :source or :output as first argument" unless [:source, :output].include?(source_or_output) 
  @examples["examples/#{name}"].send(source_or_output)
end

#examples(examples_path, erb_renderer) ⇒ Object


3
4
5
6
7
8
# File 'lib/docs/example/helper.rb', line 3

def examples(examples_path, erb_renderer)
  Dir.glob(examples_path).inject({}) do |hsh, example_name|
    hsh[example_name] = Example.new(example_name, erb_renderer)
    hsh
  end
end