Sha256: 8dcaf46e22ad51b9d463fb416a013acceed558b163af081456088fc433214a29

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

module TokyoMetro::Modules::Common::Info::Decision::CompareBase

  private

  def compare_base( *args , compared )
    raise if args.empty?

    if compared.nil?
      return false
    end

    args = args.flatten

    unless args.instance_of?( ::Array ) and args.all? { | item | item.instance_of?( ::String ) or item.instance_of?( ::Regexp ) }
      class_list = args.map { | item | item.class }
      raise "#{ class_list.to_s } is not valid."
    end
    unless compared.instance_of?( ::String ) or ( compared.instance_of?( ::Array ) and compared.all? { | item | item.instance_of?( ::String ) } )
      raise "Error: \[#{ compared.class.name }\] #{ compared.to_s }"
    end
    if compared.instance_of?( ::String )
      args.any? { | item | item === compared }
    else
      compared.any? { | compared_each_item |
        args.any? { | item | item === compared_each_item }
      }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/modules/common/info/decision/compare_base.rb