Class: Regin::Atom

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/mount/vendor/regin/regin/atom.rb

Direct Known Subclasses

Anchor, Character

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, options = {}) ⇒ Atom

Returns a new instance of Atom.



5
6
7
8
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 5

def initialize(value, options = {})
  @value = value
  @ignorecase = options[:ignorecase]
end

Instance Attribute Details

#ignorecaseObject (readonly)

Returns the value of attribute ignorecase.



3
4
5
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 3

def ignorecase
  @ignorecase
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 3

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



39
40
41
42
43
44
45
46
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 39

def ==(other) #:nodoc:
  case other
  when String
    other == to_s
  else
    eql?(other)
  end
end

#casefold?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 19

def casefold?
  ignorecase ? true : false
end

#dup(options = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 23

def dup(options = {})
  original_options = option_names.inject({}) do |h, m|
    h[m.to_sym] = send(m)
    h
  end
  self.class.new(value, original_options.merge(options))
end

#eql?(other) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 48

def eql?(other) #:nodoc:
  other.instance_of?(self.class) &&
    self.value.eql?(other.value) &&
    (!!self.ignorecase).eql?(!!other.ignorecase)
end

#inspectObject

:nodoc:



35
36
37
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 35

def inspect #:nodoc:
  "#<#{self.class.to_s.sub('Regin::', '')} #{to_s.inspect}>"
end

#literal?Boolean

Returns true if expression could be treated as a literal string.

Returns:

  • (Boolean)


15
16
17
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 15

def literal?
  false
end

#option_namesObject



10
11
12
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 10

def option_names
  %w( ignorecase )
end

#to_s(parent = false) ⇒ Object



31
32
33
# File 'lib/rack/mount/vendor/regin/regin/atom.rb', line 31

def to_s(parent = false)
  "#{value}"
end