Class: GemfileSorter::Line::Source

Inherits:
BlockOfGems show all
Defined in:
lib/gemfile_sorter/line/source.rb

Instance Attribute Summary collapse

Attributes inherited from BlockOfGems

#gems, #line, #line_number

Instance Method Summary collapse

Methods inherited from BlockOfGems

#add, #empty?, #gem_string, #leading_spaces, #to_s

Constructor Details

#initialize(name, line:, line_number:) ⇒ Source

Returns a new instance of Source.



6
7
8
9
10
# File 'lib/gemfile_sorter/line/source.rb', line 6

def initialize(name, line:, line_number:)
  @name = name
  @groups = Groups.new
  super(name, line:, line_number:)
end

Instance Attribute Details

#groupsObject

Returns the value of attribute groups.



4
5
6
# File 'lib/gemfile_sorter/line/source.rb', line 4

def groups
  @groups
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/gemfile_sorter/line/source.rb', line 4

def name
  @name
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
21
22
# File 'lib/gemfile_sorter/line/source.rb', line 18

def <=>(other)
  name <=> other.name
rescue
  raise InvalidLineComparisonError
end

#container?Boolean

Returns:

  • (Boolean)


12
# File 'lib/gemfile_sorter/line/source.rb', line 12

def container? = true

#inside_block_mapObject



14
# File 'lib/gemfile_sorter/line/source.rb', line 14

def inside_block_map = groups

#normalized_nameObject



16
# File 'lib/gemfile_sorter/line/source.rb', line 16

def normalized_name = name