method
ruby_code
v2_1_10 -
Show latest stable
- Class:
Gem::Specification
ruby_code(obj)private
Return a string containing a Ruby code representation of the given object.
# File lib/rubygems/specification.rb, line 2121
def ruby_code(obj)
case obj
when String then obj.dump
when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
when Hash then
seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
"{ #{seg.join(', ')} }"
when Gem::Version then obj.to_s.dump
when Date then obj.strftime('%Y-%m-%d').dump
when Time then obj.strftime('%Y-%m-%d').dump
when Numeric then obj.inspect
when true, false, nil then obj.inspect
when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
when Gem::Requirement then
list = obj.as_list
"Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
end
end Related methods
- Instance methods
- <=>
- ==
- _dump
- activate
- activate_dependencies
- add_bindir
- add_dependency
- add_development_dependency
- add_runtime_dependency
- add_self_to_load_path
- author
- author=
- authors
- authors=
- bin_dir
- bin_file
- build_args
- build_extensions
- build_info_dir
- build_info_file
- cache_dir
- cache_file
- conflicts
- date
- date=
- default_executable
- default_value
- dependencies
- dependent_gems
- dependent_specs
- description=
- development_dependencies
- doc_dir
- encode_with
- eql?
- executable
- executable=
- executables
- executables=
- extensions
- extensions=
- extra_rdoc_files
- extra_rdoc_files=
- file_name
- files
- files=
- for_cache
- full_name
- gem_build_complete_path
- gem_dir
- has_rdoc
- has_rdoc=
- has_rdoc?
- has_unit_tests?
- hash
- init_with
- initialize_copy
- inspect
- installed_by_version
- installed_by_version=
- lib_dirs_glob
- lib_files
- license
- license=
- licenses
- licenses=
- loaded_from=
- mark_version
- matches_for_glob
- method_missing
- name_tuple
- normalize
- original_name
- original_platform
- platform
- platform=
- pretty_print
- raise_if_conflicts
- rdoc_options
- rdoc_options=
- require_path
- require_path=
- required_ruby_version=
- required_rubygems_version=
- requirements
- requirements=
- reset_nil_attributes_to_default
- respond_to_missing?
- ri_dir
- runtime_dependencies
- satisfies_requirement?
- sort_obj
- source
- spec_dir
- spec_file
- spec_name
- stubbed?
- summary=
- test_file
- test_file=
- test_files
- test_files=
- to_ruby
- to_ruby_for_cache
- to_s
- to_spec
- to_yaml
- traverse
- validate
- validate_dependencies
- validate_permissions
- version=
- warning
- yaml_initialize
- Class methods
- _all
- _clear_load_cache
- _load
- _resort!
- add_spec
- add_specs
- all
- all=
- all_names
- array_attributes
- attribute_names
- dirs
- dirs=
- each
- each_gemspec
- each_spec
- each_stub
- find_all_by_name
- find_by_name
- find_by_path
- find_in_unresolved
- find_in_unresolved_tree
- find_inactive_by_path
- from_yaml
- latest_specs
- load
- load_defaults
- new
- non_nil_attributes
- normalize_yaml_input
- outdated
- outdated_and_latest_version
- remove_spec
- required_attribute?
- required_attributes
- reset
- stubs
- unresolved_deps
- Private methods
-
add_dependency_with_type -
find_all_satisfiers -
find_full_gem_path -
invalidate_memoized_attributes -
ruby_code -
same_attributes?