Module: AccessorUtilities::StringInstance
- Included in:
- String
- Defined in:
- lib/accessor-utilities.rb,
lib/accessor-utilities/AccessorUtilities/StringInstance.rb
Instance Method Summary collapse
-
#accessor_name ⇒ Object
accessor_name #.
-
#is_set_accessor_name ⇒ Object
is_set_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
write_accessor_name #.
Instance Method Details
#accessor_name ⇒ Object
accessor_name #
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/accessor-utilities/AccessorUtilities/StringInstance.rb', line 48 def accessor_name accessor_name_string = self last_index = length - 1 last_character = self[ last_index ] if last_character == '?' or last_character == '=' accessor_name_string = slice( 0, last_index ) else accessor_name_string = self end if accessor_name_string.is_variable_name? accessor_name_string = slice( 1, length ) end return accessor_name_string.to_sym end |
#is_set_accessor_name ⇒ Object
is_set_accessor_name #
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/accessor-utilities/AccessorUtilities/StringInstance.rb', line 105 def is_set_accessor_name is_set_accessor_name_string = nil last_index = length - 1 if self[ last_index ] == '?' and self[ 0 ] != '@' is_set_accessor_name_string = self else is_set_accessor_name_string = accessor_name.to_s + '?' end return is_set_accessor_name_string.to_sym end |
#is_variable_name? ⇒ Boolean
is_variable_name? #
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/accessor-utilities/AccessorUtilities/StringInstance.rb', line 8 def is_variable_name? is_variable_name = false last_index = length - 1 if self[ 0 ] == '@' and self[ last_index ] != '?' and self[ last_index ] != '=' is_variable_name = true end return is_variable_name end |
#swizzle_name(swizzled_method_prefix = 'swizzled__', append_equals_to_method_name = false) ⇒ Object
swizzle_name #
130 131 132 133 134 135 136 137 |
# File 'lib/accessor-utilities/AccessorUtilities/StringInstance.rb', line 130 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 #
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/accessor-utilities/AccessorUtilities/StringInstance.rb', line 30 def variable_name variable_name_string = self unless variable_name_string.is_variable_name? variable_name_string = '@' + accessor_name.to_s end return variable_name_string.to_sym end |
#write_accessor_name ⇒ Object
write_accessor_name #
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/accessor-utilities/AccessorUtilities/StringInstance.rb', line 80 def write_accessor_name write_accessor_name_string = nil last_index = length - 1 if self[ last_index ] == '=' and self[ 0 ] != '@' write_accessor_name_string = self else write_accessor_name_string = accessor_name.to_s + '=' end return write_accessor_name_string.to_sym end |