Class: Kiki::Key
- Inherits:
-
Object
- Object
- Kiki::Key
- Defined in:
- lib/kiki/key.rb
Instance Attribute Summary collapse
-
#delimiter ⇒ Object
Returns the value of attribute delimiter.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
- #for(*args) ⇒ Object
-
#initialize(namespace, delimiter, domain, identifier) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(namespace, delimiter, domain, identifier) ⇒ Key
Returns a new instance of Key.
8 9 10 11 12 13 |
# File 'lib/kiki/key.rb', line 8 def initialize(namespace, delimiter, domain, identifier) @namespace = namespace @delimiter = delimiter @domain = domain @identifier = identifier end |
Instance Attribute Details
#delimiter ⇒ Object
Returns the value of attribute delimiter.
6 7 8 |
# File 'lib/kiki/key.rb', line 6 def delimiter @delimiter end |
#domain ⇒ Object
Returns the value of attribute domain.
6 7 8 |
# File 'lib/kiki/key.rb', line 6 def domain @domain end |
#identifier ⇒ Object
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/kiki/key.rb', line 6 def identifier @identifier end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/kiki/key.rb', line 5 def namespace @namespace end |
Instance Method Details
#for(*args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kiki/key.rb', line 15 def for(*args) components = [@namespace, @domain] + args.collect do |arg| case arg when String, Numeric then arg else arg.respond_to?(@identifier) ? arg.send(@identifier) : arg.to_s end end components.compact.join(@delimiter) end |