Class: Ellipses::Client::Parser
- Inherits:
-
Object
- Object
- Ellipses::Client::Parser
- Defined in:
- lib/ellipses/client/parser.rb
Defined Under Namespace
Constant Summary collapse
- PATTERN =
/ ^ (?<prefix>\s*) (?<directive>(?:[.]|>){3,}.*) /x
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(line) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(line) ⇒ Parser
Returns a new instance of Parser.
48 49 50 |
# File 'lib/ellipses/client/parser.rb', line 48 def initialize(line) @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
46 47 48 |
# File 'lib/ellipses/client/parser.rb', line 46 def line @line end |
Class Method Details
.match?(line) ⇒ Boolean
39 40 41 |
# File 'lib/ellipses/client/parser.rb', line 39 def match?(line) !line.match(PATTERN).nil? end |
Instance Method Details
#call ⇒ Object
52 53 54 55 56 57 |
# File 'lib/ellipses/client/parser.rb', line 52 def call Shellwords.split(preprocess(line)).slice_after('|').map do |group| group.pop if group.last == '|' Lexeme.from_strings(group) end end |