Module: AwesomePrint::Bruhl
- Defined in:
- lib/bruhl/awesome_print.rb
Class Method Summary collapse
Instance Method Summary collapse
- #awesome_bruhl_object(object) ⇒ Object
- #awesome_bruhl_relation(relation) ⇒ Object
- #cast_with_bruhl(object, type) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 |
# File 'lib/bruhl/awesome_print.rb', line 5 def self.included(base) base.send :alias_method, :cast_without_bruhl, :cast base.send :alias_method, :cast, :cast_with_bruhl end |
Instance Method Details
#awesome_bruhl_object(object) ⇒ Object
20 21 22 23 24 |
# File 'lib/bruhl/awesome_print.rb', line 20 def awesome_bruhl_object(object) str = awesome_array(object.contents) str = "#{colorize(object.tag, :class)}: #{str}" if object.tag str end |
#awesome_bruhl_relation(relation) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bruhl/awesome_print.rb', line 26 def awesome_bruhl_relation(relation) right = case relation.right when ::Bruhl::Object awesome_bruhl_object(relation.right) when ::Bruhl::Relation awesome_bruhl_relation(relation.right) when ::Bruhl::RawString, ::Bruhl::QuotedString colorize(relation.right.to_s, :string) when ::Float, ::Integer relation.right.ai end [ colorize(relation.left.to_s, :method), colorize(relation.operator, :symbol), right ].join(' ') end |
#cast_with_bruhl(object, type) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/bruhl/awesome_print.rb', line 10 def cast_with_bruhl(object, type) cast = cast_without_bruhl(object, type) if defined?(::Bruhl::Object) && object.is_a?(::Bruhl::Object) cast = :bruhl_object elsif defined?(::Bruhl::Relation) && object.is_a?(::Bruhl::Relation) cast = :bruhl_relation end cast end |