Class: Array

Inherits:
Object show all
Defined in:
lib/core_ex/yaml.rb

Instance Method Summary collapse

Instance Method Details

#is_complex_yaml?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/core_ex/yaml.rb', line 159

def is_complex_yaml?
  any? { |x| x.is_complex_yaml? } or inspect.size > 80
end

#old_to_yamlObject



143
# File 'lib/core_ex/yaml.rb', line 143

alias_method :old_to_yaml, :to_yaml

#to_yaml(opts = {}) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/core_ex/yaml.rb', line 145

def to_yaml ( opts={} )
  inline = nil
  if YAML.have_option? opts, :Inline and not is_complex_yaml?
    inline = :inline
  end
  YAML::quick_emit(object_id, opts) do |out|
    out.seq( taguri, to_yaml_style || inline ) do |seq|
      each { |x| seq.add x }
    end
  end
end