Sha256: 0e9d0f87e320de2d20775830b0cc6f114d06f5c6cdb61d26cd1ec888c8e74d9a

Contents?: true

Size: 733 Bytes

Versions: 8

Compression:

Stored size: 733 Bytes

Contents

module Celerity
  module ShortInspect

    def short_inspect(opts)
      if excluded_ivars = opts[:exclude]
        if is_ruby19
          excluded_ivars.map! { |ivar| ivar.to_sym }
        end
        ivars = (instance_variables - excluded_ivars)
      elsif included_ivars = opts[:include]
        if is_ruby19
          included_ivars.map! { |ivar| ivar.to_sym }
        end
        ivars = included_ivars
      else
        raise ArgumentError, "unknown arg: #{opts.inspect}"
      end

      ivars.map! { |ivar| "#{ivar}=#{instance_variable_get(ivar).inspect}" }
      '#<%s:0x%s %s>' % [self.class.name, self.hash.to_s(16), ivars.join(" ")]
    end

    private
    def is_ruby19
      RUBY_VERSION >= "1.9"
    end

  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
celerity_thingista-0.9.3 lib/celerity/short_inspect.rb
celerity_thingista-0.9.2 lib/celerity/short_inspect.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/short_inspect.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/short_inspect.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/short_inspect.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/short_inspect.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/celerity-0.9.2/lib/celerity/short_inspect.rb
celerity-0.9.2 lib/celerity/short_inspect.rb