Class: Rebundler::GemSet

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/rebundler/gem_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, node: nil, default: false) ⇒ GemSet

Returns a new instance of GemSet.



9
10
11
12
13
14
15
16
# File 'lib/rebundler/gem_set.rb', line 9

def initialize(name: nil, node: nil, default: false)
  @name = name
  @node = node
  @default = default

  @plugins = []
  @gems = []
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



7
8
9
# File 'lib/rebundler/gem_set.rb', line 7

def default
  @default
end

#gemsObject (readonly)

Returns the value of attribute gems.



7
8
9
# File 'lib/rebundler/gem_set.rb', line 7

def gems
  @gems
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/rebundler/gem_set.rb', line 7

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



7
8
9
# File 'lib/rebundler/gem_set.rb', line 7

def node
  @node
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



7
8
9
# File 'lib/rebundler/gem_set.rb', line 7

def plugins
  @plugins
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/rebundler/gem_set.rb', line 18

def <=>(other)
  unless other.is_a?(GemSet)
    raise ArgumentError,
          "comparison of GemSet with #{other.class} failed"
  end

  # Default first, then sort by name
  [default ? 0 : 1, name.to_s] <=> [other.default ? 0 : 1, other.name.to_s]
end

#==(other) ⇒ Object



28
29
30
# File 'lib/rebundler/gem_set.rb', line 28

def ==(other)
  other.is_a?(GemSet) && other.name == name && other.default == default
end