Class: Commons::Lang::Builder::ToSStyle
- Inherits:
-
Object
- Object
- Commons::Lang::Builder::ToSStyle
- Defined in:
- lib/commons/lang/builder/to_s_style.rb
Direct Known Subclasses
DefaultToSStyle, MultiLineToSStyle, NoFieldNameToSStyle, ShortPrefixToSStyle, SimpleToSStyle
Defined Under Namespace
Classes: DefaultToSStyle, MultiLineToSStyle, NoFieldNameToSStyle, ShortPrefixToSStyle, SimpleToSStyle
Constant Summary collapse
- DEFAULT_STYLE =
DefaultToSStyle.new
- MULTI_LINE_STYLE =
MultiLineToSStyle.new
- NO_FIELD_NAMES_STYLE =
NoFieldNameToSStyle.new
- SHORT_PREFIX_STYLE =
ShortPrefixToSStyle.new
- SIMPLE_STYLE =
SimpleToSStyle.new
Instance Attribute Summary collapse
-
#array_content_detail ⇒ Object
writeonly
Sets the attribute array_content_detail.
-
#array_end ⇒ Object
writeonly
Sets the attribute array_end.
-
#array_separator ⇒ Object
writeonly
Sets the attribute array_separator.
-
#array_start ⇒ Object
writeonly
Sets the attribute array_start.
-
#content_end ⇒ Object
writeonly
Sets the attribute content_end.
-
#content_start ⇒ Object
writeonly
Sets the attribute content_start.
-
#default_full_detail ⇒ Object
writeonly
Sets the attribute default_full_detail.
-
#field_name_value_separator ⇒ Object
writeonly
Sets the attribute field_name_value_separator.
-
#field_separator ⇒ Object
writeonly
Sets the attribute field_separator.
-
#field_separator_at_end ⇒ Object
writeonly
Sets the attribute field_separator_at_end.
-
#field_separator_at_start ⇒ Object
writeonly
Sets the attribute field_separator_at_start.
-
#nil_text ⇒ Object
writeonly
Sets the attribute nil_text.
-
#size_end_text ⇒ Object
writeonly
Sets the attribute size_end_text.
-
#size_start_text ⇒ Object
writeonly
Sets the attribute size_start_text.
-
#summary_object_end_text ⇒ Object
writeonly
Sets the attribute summary_object_end_text.
-
#summary_object_start_text ⇒ Object
writeonly
Sets the attribute summary_object_start_text.
-
#use_class_name ⇒ Object
writeonly
Sets the attribute use_class_name.
-
#use_field_names ⇒ Object
writeonly
Sets the attribute use_field_names.
-
#use_identity_hash_code ⇒ Object
writeonly
Sets the attribute use_identity_hash_code.
-
#use_short_className ⇒ Object
writeonly
Sets the attribute use_short_className.
Instance Method Summary collapse
-
#append(buffer, field_name, value, full_detail) ⇒ Object
– —————————————————————————— ++.
- #append_end(buffer, object) ⇒ Object
- #append_start(buffer, object) ⇒ Object
- #append_super(buffer, super_to_s) ⇒ Object
- #append_to_s(buffer, to_s) ⇒ Object
-
#initialize ⇒ ToSStyle
constructor
A new instance of ToSStyle.
- #register(value) ⇒ Object
- #registered?(value) ⇒ Boolean
- #unregister(value) ⇒ Object
Constructor Details
#initialize ⇒ ToSStyle
Returns a new instance of ToSStyle.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 62 def initialize super() @registry = Hash.new # Whether to use the field names, the default is true. @use_field_names = true # Whether to use the class name, the default is true. @use_class_name = true # Whether to use short class names, the default is false. @use_short_className = false # Whether to use the identity hash code, the default is true. @use_identity_hash_code = true # The content start '{'. @content_start = '{' # The content end '}'. @content_end = '}' # The field name value separator '='. @field_name_value_separator = '=' # Whether the field separator should be added before any other fields. @field_separator_at_start = false # Whether the field separator should be added after any other fields. @field_separator_at_end = false # The field separator ','. @field_separator = ',' # The array start '['. @array_start = '[' # The array separator ','. @array_separator = ',' # The detail for array content. @array_content_detail = true # The array end ']'. @array_end = ']' # The value to use when fullDetail is nil, # the default value is true. @default_full_detail = true # The nil text '<nil>'. @nil_text = '<nil>' # The summary size text start '<size'. @size_start_text = '<size=' # The summary size text start '>'. @size_end_text = '>' # The summary object text start '<'. @summary_object_start_text = '<' # The summary object text start '>'. @summary_object_end_text = '>' end |
Instance Attribute Details
#array_content_detail=(value) ⇒ Object
Sets the attribute array_content_detail
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def array_content_detail=(value) @array_content_detail = value end |
#array_end=(value) ⇒ Object
Sets the attribute array_end
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def array_end=(value) @array_end = value end |
#array_separator=(value) ⇒ Object
Sets the attribute array_separator
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def array_separator=(value) @array_separator = value end |
#array_start=(value) ⇒ Object
Sets the attribute array_start
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def array_start=(value) @array_start = value end |
#content_end=(value) ⇒ Object
Sets the attribute content_end
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def content_end=(value) @content_end = value end |
#content_start=(value) ⇒ Object
Sets the attribute content_start
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def content_start=(value) @content_start = value end |
#default_full_detail=(value) ⇒ Object
Sets the attribute default_full_detail
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def default_full_detail=(value) @default_full_detail = value end |
#field_name_value_separator=(value) ⇒ Object
Sets the attribute field_name_value_separator
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def field_name_value_separator=(value) @field_name_value_separator = value end |
#field_separator=(value) ⇒ Object
Sets the attribute field_separator
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def field_separator=(value) @field_separator = value end |
#field_separator_at_end=(value) ⇒ Object
Sets the attribute field_separator_at_end
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def field_separator_at_end=(value) @field_separator_at_end = value end |
#field_separator_at_start=(value) ⇒ Object
Sets the attribute field_separator_at_start
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def field_separator_at_start=(value) @field_separator_at_start = value end |
#nil_text=(value) ⇒ Object
Sets the attribute nil_text
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def nil_text=(value) @nil_text = value end |
#size_end_text=(value) ⇒ Object
Sets the attribute size_end_text
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def size_end_text=(value) @size_end_text = value end |
#size_start_text=(value) ⇒ Object
Sets the attribute size_start_text
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def size_start_text=(value) @size_start_text = value end |
#summary_object_end_text=(value) ⇒ Object
Sets the attribute summary_object_end_text
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def summary_object_end_text=(value) @summary_object_end_text = value end |
#summary_object_start_text=(value) ⇒ Object
Sets the attribute summary_object_start_text
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def summary_object_start_text=(value) @summary_object_start_text = value end |
#use_class_name=(value) ⇒ Object
Sets the attribute use_class_name
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def use_class_name=(value) @use_class_name = value end |
#use_field_names=(value) ⇒ Object
Sets the attribute use_field_names
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def use_field_names=(value) @use_field_names = value end |
#use_identity_hash_code=(value) ⇒ Object
Sets the attribute use_identity_hash_code
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def use_identity_hash_code=(value) @use_identity_hash_code = value end |
#use_short_className=(value) ⇒ Object
Sets the attribute use_short_className
43 44 45 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 43 def use_short_className=(value) @use_short_className = value end |
Instance Method Details
#append(buffer, field_name, value, full_detail) ⇒ Object
– —————————————————————————— ++
209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 209 def append(buffer, field_name, value, full_detail) append_field_start(buffer, field_name) if value == nil append_nil_text(buffer, field_name) else append_internal(buffer, field_name, value, full_detail) end append_field_end(buffer, field_name) end |
#append_end(buffer, object) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 180 def append_end(buffer, object) if @field_separator_at_end == false remove_last_field_separator(buffer) end append_content_end(buffer) end |
#append_start(buffer, object) ⇒ Object
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 168 def append_start(buffer, object) if object != nil append_class_name(buffer, object) append_identity_hash_code(buffer, object) append_content_start(buffer) if @field_separator_at_start append_field_separator(buffer) end end end |
#append_super(buffer, super_to_s) ⇒ Object
147 148 149 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 147 def append_super(buffer, super_to_s) append_to_s(buffer, super_to_s) end |
#append_to_s(buffer, to_s) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 152 def append_to_s(buffer, to_s) if to_s != nil pos1 = to_s.index(@content_start) + @content_start.length pos2 = to_s.rindex(@content_end) if pos1 != pos2 && pos1 >= 0 && pos2 >= 0 data = to_s[pos1 ... pos2] if @field_separator_at_start remove_last_field_separator(buffer) end buffer.concat(data) append_field_separator(buffer) end end end |
#register(value) ⇒ Object
135 136 137 138 139 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 135 def register(value) if value != nil @registry[value.__id__] = value end end |
#registered?(value) ⇒ Boolean
130 131 132 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 130 def registered?(value) return @registry.has_key?(value.__id__) end |
#unregister(value) ⇒ Object
142 143 144 |
# File 'lib/commons/lang/builder/to_s_style.rb', line 142 def unregister(value) @registry.delete(value.__id__); end |