Class: Arstotzka::KeyChanger Private
- Inherits:
-
Object
- Object
- Arstotzka::KeyChanger
- Includes:
- Base
- Defined in:
- lib/arstotzka/key_changer.rb
Overview
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.
Class responsible for changing a key
Instance Attribute Summary collapse
- #base_key ⇒ Object readonly private private
- #options ⇒ Object readonly private private
Instance Method Summary collapse
-
#initialize(base_key, options_hash = {}) ⇒ KeyChanger
constructor
private
A new instance of KeyChanger.
-
#key ⇒ String
private
Transforms the key to have the correct case.
Methods included from Base
Constructor Details
#initialize(base_key, options_hash) ⇒ KeyChanger #initialize(base_key, options) ⇒ KeyChanger
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 KeyChanger.
26 27 28 29 |
# File 'lib/arstotzka/key_changer.rb', line 26 def initialize(base_key, = {}) self. = @base_key = base_key end |
Instance Attribute Details
#base_key ⇒ Object (readonly, private)
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.
52 53 54 |
# File 'lib/arstotzka/key_changer.rb', line 52 def base_key @base_key end |
#options ⇒ Object (readonly, private)
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.
52 53 54 |
# File 'lib/arstotzka/key_changer.rb', line 52 def @options end |
Instance Method Details
#key ⇒ String
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.
Transforms the key to have the correct case
the possible cases (instance attribute) are
-
lower_camel: for cammel case with first letter lowercase
-
upper_camel: for cammel case with first letter uppercase
-
snake: for snake case
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/arstotzka/key_changer.rb', line 39 def key @key ||= case .case when :lower_camel base_key.camelize(:lower) when :upper_camel base_key.camelize(:upper) when :snake base_key.underscore end end |