Class: Avmtrf1::Openvpn::Config::Parser::Line

Inherits:
Object
  • Object
show all
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

Instance Method Details

#blank_text?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 22

def blank_text?
  text.blank?
end

#close_tag?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


26
27
28
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 26

def open_tag?
  OPEN_TAG_PATTERN.match?(text)
end

#simple_partsObject



18
19
20
# File 'lib/avmtrf1/openvpn/config/parser/line.rb', line 18

def simple_parts
  ::Shellwords.split(text)
end

#tag_nameObject



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