Class: Tweezer::Gem
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ASTHelper
append_block_child, #blank_line, block?, block_children, group_block?, groups_from_group_block, s, source_block?, unparse_hash_node
Constructor Details
#initialize(node_or_name, opts = {}) ⇒ Gem
5
6
7
8
9
10
11
|
# File 'lib/tweezer/gem.rb', line 5
def initialize(node_or_name, opts = {})
return init_from_node(node_or_name) if node_or_name.is_a?(
Parser::AST::Node)
@name = node_or_name
alter!(opts)
end
|
Instance Attribute Details
#groups ⇒ Object
42
43
44
|
# File 'lib/tweezer/gem.rb', line 42
def groups
@groups ||= []
end
|
#name ⇒ Object
Returns the value of attribute name.
38
39
40
|
# File 'lib/tweezer/gem.rb', line 38
def name
@name
end
|
#path ⇒ Object
Returns the value of attribute path.
39
40
41
|
# File 'lib/tweezer/gem.rb', line 39
def path
@path
end
|
#version ⇒ Object
Returns the value of attribute version.
39
40
41
|
# File 'lib/tweezer/gem.rb', line 39
def version
@version
end
|
Class Method Details
.gem_node?(node) ⇒ Boolean
34
35
36
|
# File 'lib/tweezer/gem.rb', line 34
def self.gem_node?(node)
node.children[1] == :gem
end
|
Instance Method Details
#==(other) ⇒ Object
29
30
31
32
|
# File 'lib/tweezer/gem.rb', line 29
def ==(other)
name == other.name &&
version == other.version
end
|
#alter!(opts) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/tweezer/gem.rb', line 13
def alter!(opts)
@version = opts[:version]
@groups = opts[:groups]
@path = opts[:path]
@opts = opts
end
|
#to_node ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/tweezer/gem.rb', line 20
def to_node
args = [nil, :gem, s(:str, name)]
args << s(:str, version) if version
opts_node = opts_to_node
args << opts_node if opts_node
Parser::AST::Node.new(:send, args)
end
|