Class: I18n::Index::Key
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(key) ⇒ Key
constructor
A new instance of Key.
- #matches?(*keys) ⇒ Boolean
Constructor Details
#initialize(key) ⇒ Key
Returns a new instance of Key.
20 21 22 |
# File 'lib/i18n/index/key.rb', line 20 def initialize(key) self.key = key end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
18 19 20 |
# File 'lib/i18n/index/key.rb', line 18 def key @key end |
Class Method Details
.pattern(key) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/i18n/index/key.rb', line 9 def pattern(key) key = key.to_s.dup match_start = key.gsub!(/^\*/, '') ? '' : '^' match_end = key.gsub!(/\*$/, '') ? '' : '$' pattern = Regexp.escape("#{key}") /#{match_start}#{pattern}#{match_end}/ end |
.patterns(*keys) ⇒ Object
5 6 7 |
# File 'lib/i18n/index/key.rb', line 5 def patterns(*keys) keys.inject({}) { |result, key| result[key] = pattern(key); result } end |
Instance Method Details
#<=>(other) ⇒ Object
31 32 33 |
# File 'lib/i18n/index/key.rb', line 31 def <=>(other) key <=> other.key end |
#==(other) ⇒ Object Also known as: eql?
35 36 37 |
# File 'lib/i18n/index/key.rb', line 35 def ==(other) key == (other.respond_to?(:key) ? other.key : other) end |
#hash ⇒ Object
40 41 42 |
# File 'lib/i18n/index/key.rb', line 40 def hash key.hash end |