Module: AccessorUtilities::StringInstance
- Defined in:
- lib/accessor_utilities/string_instance.rb
Instance Method Summary collapse
-
#accessor_name ⇒ Object
(also: #accessor)
accessor_name #.
-
#is_variable_name? ⇒ Boolean
is_variable_name? #.
-
#swizzle_name(swizzled_method_prefix = 'swizzled__', append_equals_to_method_name = false) ⇒ Object
swizzle_name #.
-
#variable_name ⇒ Object
variable_name #.
-
#write_accessor_name ⇒ Object
(also: #write_accessor)
write_accessor_name #.
Instance Method Details
#accessor_name ⇒ Object Also known as: accessor
accessor_name #
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/accessor_utilities/string_instance.rb', line 25 def accessor_name return_value = nil case self[ -1 ] when '=' return_value = slice( 0, length - 1 ) else return_value = is_variable_name? ? self.slice( 1, length ).to_sym : to_sym end return return_value end |
#is_variable_name? ⇒ Boolean
is_variable_name? #
9 10 11 |
# File 'lib/accessor_utilities/string_instance.rb', line 9 def is_variable_name? return self[ 0 ] == '@' end |
#swizzle_name(swizzled_method_prefix = 'swizzled__', append_equals_to_method_name = false) ⇒ Object
swizzle_name #
80 81 82 83 84 85 86 87 |
# File 'lib/accessor_utilities/string_instance.rb', line 80 def swizzle_name( swizzled_method_prefix = 'swizzled__', append_equals_to_method_name = false ) swizzled_method_name = ( swizzled_method_prefix.to_s + to_s ) swizzled_method_name = swizzled_method_name.write_accessor_name if append_equals_to_method_name return swizzled_method_name.to_sym end |
#variable_name ⇒ Object
variable_name #
17 18 19 |
# File 'lib/accessor_utilities/string_instance.rb', line 17 def variable_name return ( is_variable_name? ? to_sym : ( '@' + self ).to_sym ) end |
#write_accessor_name ⇒ Object Also known as: write_accessor
write_accessor_name #
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/accessor_utilities/string_instance.rb', line 50 def write_accessor_name return_value = nil case self[ -1 ] when '?' return_value = self.dup return_value[ -1 ] = '=' when '=' return_value = to_sym else return_value = ( self + '=' ).to_sym end return return_value end |