Class: Avmtrf1::Openvpn::Config::Parser::Line
- Inherits:
-
Object
- Object
- Avmtrf1::Openvpn::Config::Parser::Line
- Defined in:
- lib/avmtrf1/openvpn/config/parser/line.rb
Constant Summary collapse
- OPEN_TAG_PATTERN =
/\A<(.+)>\z/.freeze
- CLOSE_TAG_PATTERN =
%r{\A</(.+)>\z}.freeze
- SIMPLE_PATTERN =
/\A(\S+)(?:\s+(\S.*))\z/.freeze
Instance Method Summary collapse
- #blank_text? ⇒ Boolean
- #close_tag? ⇒ Boolean
- #open_tag? ⇒ Boolean
- #simple_parts ⇒ Object
- #tag_name ⇒ Object
Instance Method Details
#blank_text? ⇒ Boolean
22 23 24 |
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 22 def blank_text? text.blank? end |
#close_tag? ⇒ Boolean
30 31 32 |
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 30 def close_tag? CLOSE_TAG_PATTERN.match?(text) end |
#open_tag? ⇒ Boolean
26 27 28 |
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 26 def open_tag? OPEN_TAG_PATTERN.match?(text) end |
#simple_parts ⇒ Object
18 19 20 |
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 18 def simple_parts ::Shellwords.split(text) end |
#tag_name ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 34 def tag_name if close_tag? CLOSE_TAG_PATTERN.if_match(text) { |m| m[1] } elsif open_tag? OPEN_TAG_PATTERN.if_match(text) { |m| m[1] } else raise "Unmapped branch in #{__method__}" end end |