Class: RGlob::Glob
- Inherits:
-
Object
- Object
- RGlob::Glob
- Defined in:
- lib/rglob.rb
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Class Method Summary collapse
- .compile(pattern) ⇒ Object
- .escape(str) ⇒ Object (also: quote)
- .last_match(*args) ⇒ Object
- .union(*patterns) ⇒ Object
Instance Method Summary collapse
- #&(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #===(str) ⇒ Object
- #casefold? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(pattern) ⇒ Glob
constructor
A new instance of Glob.
- #kcode ⇒ Object
- #match(str) ⇒ Object
- #options ⇒ Object
- #source ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(pattern) ⇒ Glob
Returns a new instance of Glob.
16 17 18 19 20 21 22 23 24 |
# File 'lib/rglob.rb', line 16 def initialize(pattern) if pattern.is_a?(Regexp) @pattern = nil @regexp = pattern else @pattern = pattern @regexp = RGlob::pattern_to_regexp(pattern) end end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
14 15 16 |
# File 'lib/rglob.rb', line 14 def pattern @pattern end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
14 15 16 |
# File 'lib/rglob.rb', line 14 def regexp @regexp end |
Class Method Details
.compile(pattern) ⇒ Object
72 73 74 |
# File 'lib/rglob.rb', line 72 def compile(pattern) Glob.new(pattern) end |
.escape(str) ⇒ Object Also known as: quote
76 77 78 |
# File 'lib/rglob.rb', line 76 def escape(str) raise NotImplementedError.new end |
.last_match(*args) ⇒ Object
81 82 83 |
# File 'lib/rglob.rb', line 81 def last_match(*args) raise NotImplementedError.new end |
.union(*patterns) ⇒ Object
85 86 87 |
# File 'lib/rglob.rb', line 85 def union(*patterns) raise NotImplementedError.new end |
Instance Method Details
#&(other) ⇒ Object
26 27 28 |
# File 'lib/rglob.rb', line 26 def &(other) Glob.new(regexp & other.regexp) end |
#==(other) ⇒ Object Also known as: eql?
30 31 32 33 34 35 36 |
# File 'lib/rglob.rb', line 30 def ==(other) if other.is_a?(Glob) other = other.regexp end regexp == other end |
#===(str) ⇒ Object
39 40 41 |
# File 'lib/rglob.rb', line 39 def ===(str) regexp === str end |
#casefold? ⇒ Boolean
43 44 45 |
# File 'lib/rglob.rb', line 43 def casefold? false end |
#hash ⇒ Object
47 48 49 |
# File 'lib/rglob.rb', line 47 def hash regexp.hash end |
#kcode ⇒ Object
51 52 53 |
# File 'lib/rglob.rb', line 51 def kcode regexp.kcode end |
#match(str) ⇒ Object
55 56 57 |
# File 'lib/rglob.rb', line 55 def match(str) regexp.match(str) end |
#options ⇒ Object
59 60 61 |
# File 'lib/rglob.rb', line 59 def 0 end |
#source ⇒ Object
63 64 65 |
# File 'lib/rglob.rb', line 63 def source pattern || regexp.source end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/rglob.rb', line 67 def to_s pattern || regexp.to_s end |