Class: Keytar::Key
- Inherits:
-
Object
- Object
- Keytar::Key
- Defined in:
- lib/keytar.rb
Overview
cannot change :order can change :unique
Instance Attribute Summary collapse
-
#delimiter ⇒ Object
Returns the value of attribute delimiter.
-
#key_case ⇒ Object
Returns the value of attribute key_case.
-
#options ⇒ Object
Returns the value of attribute options.
-
#order ⇒ Object
Returns the value of attribute order.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Key
constructor
A new instance of Key.
- #key_array ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Key
Returns a new instance of Key.
17 18 19 20 21 22 23 |
# File 'lib/keytar.rb', line 17 def initialize( = {}) [:name] = .delete(:name).to_s.gsub(/(^key$|_key$)/, '') self.delimiter = .delete(:delimiter) self.order = .delete(:order) self.key_case = .delete(:key_case) self. = end |
Instance Attribute Details
#delimiter ⇒ Object
Returns the value of attribute delimiter.
16 17 18 |
# File 'lib/keytar.rb', line 16 def delimiter @delimiter end |
#key_case ⇒ Object
Returns the value of attribute key_case.
16 17 18 |
# File 'lib/keytar.rb', line 16 def key_case @key_case end |
#options ⇒ Object
Returns the value of attribute options.
16 17 18 |
# File 'lib/keytar.rb', line 16 def @options end |
#order ⇒ Object
Returns the value of attribute order.
16 17 18 |
# File 'lib/keytar.rb', line 16 def order @order end |
Class Method Details
.build(options = {}) ⇒ Object
35 36 37 |
# File 'lib/keytar.rb', line 35 def self.build( = {}) self.new().to_s end |
Instance Method Details
#key_array ⇒ Object
25 26 27 |
# File 'lib/keytar.rb', line 25 def key_array order.map {|key| [key]}.flatten.compact.map(&:to_s) end |
#to_s ⇒ Object
29 30 31 32 33 |
# File 'lib/keytar.rb', line 29 def to_s key = key_array.join(delimiter) key = key.send key_case if key_case.present? && key.respond_to?(key_case) key end |