Sha256: 96473c8807ac4e1576bc9f4c02b671257b35b6bc51ced7ee2a9459ca8dab8bbf

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

# $Id$
#
# = yaml/syck.rb:
#

require 'stringio'
require 'syck/syck'
require 'syck/error'
require 'syck/syck'
require 'syck/tag'
require 'syck/stream'
require 'syck/constants'
require 'syck/rubytypes'
require 'syck/types'

module Syck
  #--
  # For Rubinius, replaces the rb_iterate call to syck_set_ivars.
  #++
  def self.set_ivars(hsh, obj)
    hsh.each do |key, value|
      obj.instance_variable_set :"@#{key}", value
    end
  end

  #--
  # For Rubinius, replaces the rb_iterate call to syck_merge_i.
  #++
  def self.merge_i(ary, hsh)
    ary.each do |entry|
      begin
        entry = Rubinius::Type.coerce_to entry, Hash, :to_hash
        hsh.update entry
      rescue
        # ignore coercion errors
      end
    end

    nil
  end

  #--
  # For Rubinius, replaces rb_syck_mktime.
  #++
  def self.mktime(str)
    require "date"
    begin
      DateTime.parse(str).to_time
    rescue ArgumentError
      # nothing
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubysl-syck-2.0.2 lib/rubysl/syck/syck.rb