Class: DocDigger::LineParser
- Inherits:
-
Object
- Object
- DocDigger::LineParser
- Defined in:
- lib/doc-digger/line_parser.rb
Constant Summary collapse
- PICKS =
{ java: /\A\s*\*/, erlang: /\A\s*%/, perl: /\A\s*#/ }
- COMMANDS =
/\A@(doc(\_state)?|res(\_(param|response|state|bind))?|cmd\_(def|use))\Z/- PARAMETER_LOCATIONS =
/\Apath|query|header|form|body\Z/- RESPONSE_LOCATIONS =
/\Aheader|body\Z/
Instance Method Summary collapse
- #indentation ⇒ Object
-
#initialize(str, clazz) ⇒ LineParser
constructor
A new instance of LineParser.
- #parse ⇒ Object
Constructor Details
#initialize(str, clazz) ⇒ LineParser
Returns a new instance of LineParser.
9 10 11 12 13 |
# File 'lib/doc-digger/line_parser.rb', line 9 def initialize(str, clazz) @clazz = clazz pick = PICKS[clazz] @str = pick.nil? ? str : str.gsub(pick, '') end |
Instance Method Details
#indentation ⇒ Object
25 26 27 |
# File 'lib/doc-digger/line_parser.rb', line 25 def indentation @indentation ||= @str.match(/\A\s*/)[0].length end |
#parse ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/doc-digger/line_parser.rb', line 15 def parse parts = @str.strip.split(/\s+/) command = parts[0].to_s.match(COMMANDS) if command.nil? || command[1].nil? { type: :joint, text: @str } else send(command[1], parts[1..-1], command) end end |