Sha256: d103c26277cdb2b70e709f38f4ed8301b9554784781c3f2f916623baffec3ed9

Contents?: true

Size: 574 Bytes

Versions: 9

Compression:

Stored size: 574 Bytes

Contents

module Bioshogi
  class Source
    class << self
      def wrap(value)
        if value.kind_of? self
          return value
        end
        new(value)
      end
    end

    private_class_method :new

    def initialize(str)
      if str.respond_to?(:expand_path)
        str = str.expand_path
      end
      if str.respond_to?(:read)
        str = str.read
      end
      str = str.to_s.toutf8.rstrip + "\n"
      str = str.gsub(/\p{blank}*\R/, "\n") # バイナリだとここで死ぬ
      @value = str.freeze
    end

    def to_s
      @value
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bioshogi-0.0.15 lib/bioshogi/source.rb
bioshogi-0.0.14 lib/bioshogi/source.rb
bioshogi-0.0.10 lib/bioshogi/source.rb
bioshogi-0.0.9 lib/bioshogi/source.rb
bioshogi-0.0.8 lib/bioshogi/source.rb
bioshogi-0.0.7 lib/bioshogi/source.rb
bioshogi-0.0.5 lib/bioshogi/source.rb
bioshogi-0.0.4 lib/bioshogi/source.rb
bioshogi-0.0.3 lib/bioshogi/source.rb