Class: Ya2YAML

Inherits:
Object show all
Includes:
Constants
Defined in:
lib/ya2yaml.rb

Overview

$Id: ya2yaml.rb,v 0.26 2007-01-19 20:42:42+09 funai Exp funai $

Author

Akira FUNAI

Copyright

Copyright © 2006 Akira FUNAI

License

MIT License

Defined Under Namespace

Modules: Constants

Constant Summary

Constants included from Constants

Constants::ESCAPE_SEQ, Constants::ESCAPE_SEQ_LB, Constants::ESCAPE_SEQ_NS, Constants::ESCAPE_SEQ_WS, Constants::REX_ANY_LB, Constants::REX_BOOL, Constants::REX_CR, Constants::REX_CRLF, Constants::REX_FLOAT, Constants::REX_INT, Constants::REX_LF, Constants::REX_LS, Constants::REX_MERGE, Constants::REX_NEL, Constants::REX_NORMAL_LB, Constants::REX_NULL, Constants::REX_PS, Constants::REX_TIMESTAMP, Constants::REX_VALUE, Constants::UCS_0X2028, Constants::UCS_0X2029, Constants::UCS_0X85, Constants::UCS_0XA0

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Ya2YAML

Returns a new instance of Ya2YAML.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ya2yaml.rb', line 11

def initialize(options = {})
  options[:indent_size] = 2          if options[:indent_size].to_i <= 0
  options[:minimum_block_length] = 0 if options[:minimum_block_length].to_i <= 0
  options.update(
    {
      :printable_with_syck  => true,
      :escape_b_specific    => true,
      :escape_as_utf8       => true,
    }
  ) if options[:syck_compatible]

  @options = options
end

Instance Method Details

#_ya2yaml(obj) ⇒ Object



25
26
27
28
# File 'lib/ya2yaml.rb', line 25

def _ya2yaml(obj)
  throw 'set $KCODE to "UTF8".' if $KCODE != 'UTF8'
  '--- ' + emit(obj,1) + "\n"
end