Sha256: 5b41da9e2fc4c11a2088c9700c1d048c140ff7f51a0c17be6163aef2d0e871a8
Contents?: true
Size: 744 Bytes
Versions: 20
Compression:
Stored size: 744 Bytes
Contents
module Gattica # Common output methods that are sharable module Convertible # output as hash def to_h output = {} instance_variables.each do |var| output.merge!({ var[1..-1] => instance_variable_get(var) }) unless var == '@xml' # exclude the whole XML dump end output end # output nice inspect syntax def to_s to_h.inspect end alias inspect to_s def to_query to_h.to_query end # Return the raw XML (if the object has a @xml instance variable, otherwise convert the object itself to xml) def to_xml if @xml @xml else self.to_xml end end alias to_yml to_yaml end end
Version data entries
20 entries across 20 versions & 6 rubygems