Sha256: 34de1bef7d9a3f452aca8e34a388ef05e84ec6c9b05255de184edb1961395010

Contents?: true

Size: 842 Bytes

Versions: 55

Compression:

Stored size: 842 Bytes

Contents

require 'mspec/utils/version'
require 'mspec/guards/guard'

class Object
  # Accepts either a single argument or an Array of arguments. If RUBY_VERSION
  # is less than 1.9, converts the argument(s) to Strings; otherwise, converts
  # the argument(s) to Symbols.
  #
  # If one argument is passed, the converted argument is returned. If an Array
  # is passed, an Array is returned.
  #
  # For example, if RUBY_VERSION == 1.8.7
  #
  #   stasy(:some) => "some"
  #   stasy("nom") => "nom"
  #
  # while if RUBY_VERSION == 1.9.0
  #
  #   stasy(:some) => :some
  #   stasy("nom") => :nom

  def stasy(one, *rest)
    era = SpecVersion.new(SpecGuard.ruby_version) < "1.9"
    convert = era ? :to_s : :to_sym

    one = one.send convert
    if rest.empty?
      one
    else
      [one].concat rest.map { |x| x.send convert }
    end
  end
end

Version data entries

55 entries across 55 versions & 3 rubygems

Version Path
rhodes-5.5.18 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.17 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.15 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.0.22 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.2 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.0.7 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.0.3 lib/extensions/mspec/mspec/helpers/stasy.rb
rhodes-5.5.0 lib/extensions/mspec/mspec/helpers/stasy.rb
tauplatform-1.0.3 lib/extensions/mspec/mspec/helpers/stasy.rb
mspec-1.9.1 lib/mspec/helpers/stasy.rb
mspec-1.9.0 lib/mspec/helpers/stasy.rb
tauplatform-1.0.2 lib/extensions/mspec/mspec/helpers/stasy.rb
tauplatform-1.0.1 lib/extensions/mspec/mspec/helpers/stasy.rb
mspec-1.8.0 lib/mspec/helpers/stasy.rb
mspec-1.7.0 lib/mspec/helpers/stasy.rb
mspec-1.6.0 lib/mspec/helpers/stasy.rb
mspec-1.5.21 lib/mspec/helpers/stasy.rb
mspec-1.5.20 lib/mspec/helpers/stasy.rb
mspec-1.5.19 lib/mspec/helpers/stasy.rb
mspec-1.5.18 lib/mspec/helpers/stasy.rb