Class: RGlob::Glob

Inherits:
Object
  • Object
show all
Defined in:
lib/rglob.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#patternObject (readonly)

Returns the value of attribute pattern.



14
15
16
# File 'lib/rglob.rb', line 14

def pattern
  @pattern
end

#regexpObject (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

Raises:

  • (NotImplementedError)


76
77
78
# File 'lib/rglob.rb', line 76

def escape(str)
  raise NotImplementedError.new
end

.last_match(*args) ⇒ Object

Raises:

  • (NotImplementedError)


81
82
83
# File 'lib/rglob.rb', line 81

def last_match(*args)
  raise NotImplementedError.new
end

.union(*patterns) ⇒ Object

Raises:

  • (NotImplementedError)


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

Returns:

  • (Boolean)


43
44
45
# File 'lib/rglob.rb', line 43

def casefold?
  false
end

#hashObject



47
48
49
# File 'lib/rglob.rb', line 47

def hash
  regexp.hash
end

#kcodeObject



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

#optionsObject



59
60
61
# File 'lib/rglob.rb', line 59

def options
  0
end

#sourceObject



63
64
65
# File 'lib/rglob.rb', line 63

def source
  pattern || regexp.source
end

#to_sObject



67
68
69
# File 'lib/rglob.rb', line 67

def to_s
  pattern || regexp.to_s
end