Class: Bundler::GemBytes::Actions::Gemspec::Attribute

Inherits:
Struct
  • Object
show all
Defined in:
lib/bundler/gem_bytes/actions/gemspec/attribute.rb

Overview

Holds the components of a attribute: a name and a value

Attributes in the gemspec look like the following:

“‘ruby Gem::Specification.new do |spec|

spec.name = 'test'

end “‘

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameString (readonly)

The name of the attribute

Examples:

attribute.name #=> "test"

Returns:

  • (String)


45
46
47
# File 'lib/bundler/gem_bytes/actions/gemspec/attribute.rb', line 45

Attribute = Struct.new(:name, :value) do
  def to_a = [name, value.to_sexp_array]
end

#valueParser::AST::Node (readonly)

The value of the attribute expressed as an AST tree

Examples:

attribute.value.to_sexp #=> 's(:str, "my_description")'

Returns:

  • (Parser::AST::Node)


45
46
47
# File 'lib/bundler/gem_bytes/actions/gemspec/attribute.rb', line 45

Attribute = Struct.new(:name, :value) do
  def to_a = [name, value.to_sexp_array]
end

Instance Method Details

#to_aArray

Converts the attribute into an array

Examples:

dependency.to_a #=> ["description", [:str, "my_description"]]

Returns:

  • (Array)


45
46
47
# File 'lib/bundler/gem_bytes/actions/gemspec/attribute.rb', line 45

Attribute = Struct.new(:name, :value) do
  def to_a = [name, value.to_sexp_array]
end