Class: AwesomePrint::Formatters::LycraAttributesFormatter
- Inherits:
-
HashFormatter
- Object
- HashFormatter
- AwesomePrint::Formatters::LycraAttributesFormatter
- Defined in:
- lib/awesome_print/formatters/lycra_attributes_formatter.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#inspector ⇒ Object
readonly
Returns the value of attribute inspector.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(attributes, inspector) ⇒ LycraAttributesFormatter
constructor
A new instance of LycraAttributesFormatter.
Constructor Details
#initialize(attributes, inspector) ⇒ LycraAttributesFormatter
Returns a new instance of LycraAttributesFormatter.
6 7 8 9 10 |
# File 'lib/awesome_print/formatters/lycra_attributes_formatter.rb', line 6 def initialize(attributes, inspector) @attributes = attributes @inspector = inspector @options = inspector. end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/awesome_print/formatters/lycra_attributes_formatter.rb', line 4 def attributes @attributes end |
#inspector ⇒ Object (readonly)
Returns the value of attribute inspector.
4 5 6 |
# File 'lib/awesome_print/formatters/lycra_attributes_formatter.rb', line 4 def inspector @inspector end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/awesome_print/formatters/lycra_attributes_formatter.rb', line 4 def @options end |
Instance Method Details
#format ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/awesome_print/formatters/lycra_attributes_formatter.rb', line 12 def format padding = attributes.keys.map { |k| k.to_s.length }.max attrs = attributes.values.map do |attr| LycraAttributeFormatter.new(attr, inspector, padding: padding).format end if [:multiline] "#{attributes.to_s} {\n#{attrs.join("\n")}\n#{outdent}}" else "#{attributes.to_s} { #{attrs.join(", ")} }" end end |