Class: Travis::Conditions::V1::Regex
- Inherits:
-
Object
- Object
- Travis::Conditions::V1::Regex
- Extended by:
- Forwardable
- Defined in:
- lib/travis/conditions/v1/regex.rb
Constant Summary collapse
- REGEX =
%r(\S*[^\s\)]+)
- DELIM =
'/'
- ESC =
'\\'
Instance Attribute Summary collapse
-
#str ⇒ Object
readonly
Returns the value of attribute str.
Instance Method Summary collapse
-
#initialize(str) ⇒ Regex
constructor
A new instance of Regex.
- #read ⇒ Object
- #regex ⇒ Object
- #scan ⇒ Object
- #word ⇒ Object
Constructor Details
#initialize(str) ⇒ Regex
Returns a new instance of Regex.
17 18 19 20 |
# File 'lib/travis/conditions/v1/regex.rb', line 17 def initialize(str) @str = StringScanner.new(str.to_s.strip) @esc = false end |
Instance Attribute Details
#str ⇒ Object (readonly)
Returns the value of attribute str.
15 16 17 |
# File 'lib/travis/conditions/v1/regex.rb', line 15 def str @str end |
Instance Method Details
#read ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/travis/conditions/v1/regex.rb', line 39 def read char = peek(1) if char == DELIM && !@esc :eos elsif char == ESC @esc = true getch else @esc = false getch end end |
#regex ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/travis/conditions/v1/regex.rb', line 31 def regex return unless peek(1) == DELIM && reg = getch char = nil reg << char while (char = read) && char != :eos reg << DELIM if char == :eos reg unless reg.empty? end |
#scan ⇒ Object
22 23 24 |
# File 'lib/travis/conditions/v1/regex.rb', line 22 def scan word || regex end |