Class: CabbageDoc::Example

Inherits:
Object
  • Object
show all
Includes:
Parser
Defined in:
lib/cabbage_doc/example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parser

included, #parse_option, #parse_templates

Constructor Details

#initializeExample

Returns a new instance of Example.



7
8
9
# File 'lib/cabbage_doc/example.rb', line 7

def initialize
  @params = {}
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/cabbage_doc/example.rb', line 5

def label
  @label
end

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/cabbage_doc/example.rb', line 5

def params
  @params
end

Instance Method Details

#parse(text) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/cabbage_doc/example.rb', line 11

def parse(text)
  m = text.match(/^(.*?)\s+-\s+(\(.*?\))$/)
  return false unless m

  @label = m[1].strip
  @params = parse_option(m[2].strip)

  valid?
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/cabbage_doc/example.rb', line 21

def valid?
  !@label.nil?
end