Class: Cinch::Pattern Private
- Inherits:
-
Object
- Object
- Cinch::Pattern
- Defined in:
- lib/cinch/pattern.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #pattern ⇒ Object readonly private
- #prefix ⇒ Object readonly private
- #suffix ⇒ Object readonly private
Class Method Summary collapse
- .obj_to_r(obj) ⇒ Regexp? private
- .resolve_proc(obj, msg = nil) ⇒ Object private
Instance Method Summary collapse
-
#initialize(prefix, pattern, suffix) ⇒ Pattern
constructor
private
A new instance of Pattern.
- #to_r(msg = nil) ⇒ Object private
Constructor Details
#initialize(prefix, pattern, suffix) ⇒ Pattern
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Pattern.
28 29 30 |
# File 'lib/cinch/pattern.rb', line 28 def initialize(prefix, pattern, suffix) @prefix, @pattern, @suffix = prefix, pattern, suffix end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/cinch/pattern.rb', line 27 def pattern @pattern end |
#prefix ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/cinch/pattern.rb', line 25 def prefix @prefix end |
#suffix ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/cinch/pattern.rb', line 26 def suffix @suffix end |
Class Method Details
.obj_to_r(obj) ⇒ Regexp?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 11 12 13 14 15 |
# File 'lib/cinch/pattern.rb', line 8 def self.obj_to_r(obj) case obj when Regexp, NilClass return obj else return Regexp.new(Regexp.escape(obj.to_s)) end end |
.resolve_proc(obj, msg = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 |
# File 'lib/cinch/pattern.rb', line 17 def self.resolve_proc(obj, msg = nil) if obj.is_a?(Proc) return resolve_proc(obj.call(msg), msg) else return obj end end |
Instance Method Details
#to_r(msg = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cinch/pattern.rb', line 32 def to_r(msg = nil) prefix = Pattern.obj_to_r(Pattern.resolve_proc(@prefix, msg)) suffix = Pattern.obj_to_r(Pattern.resolve_proc(@suffix, msg)) pattern = Pattern.resolve_proc(@pattern, msg) case pattern when Regexp, NilClass /#{prefix}#{pattern}#{suffix}/ else /^#{prefix}#{Pattern.obj_to_r(pattern)}#{suffix}$/ end end |