Class: RakeContentFile::DependencyList

Inherits:
Object
  • Object
show all
Defined in:
lib/rake-file-content/dependency_list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDependencyList

Returns a new instance of DependencyList.



5
6
7
# File 'lib/rake-file-content/dependency_list.rb', line 5

def initialize
  @list = []
end

Instance Attribute Details

#listObject

Returns the value of attribute list.



3
4
5
# File 'lib/rake-file-content/dependency_list.rb', line 3

def list
  @list
end

Class Method Details

.deserialize(data) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/rake-file-content/dependency_list.rb', line 31

def self.deserialize(data)
  deps = self.new

  data.lines do |line|
    deps.list << line.chomp.split(": ")
  end
  
  deps
end

Instance Method Details

#==(other) ⇒ Object



9
10
11
# File 'lib/rake-file-content/dependency_list.rb', line 9

def ==(other)
  sorted_list == other.sorted_list
end

#add(name, hash) ⇒ Object



17
18
19
# File 'lib/rake-file-content/dependency_list.rb', line 17

def add(name, hash)
  list << [name, hash]
end

#serializeObject



21
22
23
24
25
26
27
28
29
# File 'lib/rake-file-content/dependency_list.rb', line 21

def serialize
  data = ""

  sorted_list.each do |dep_name, hash|
    data << "#{dep_name}: #{hash}\n"
  end

  data
end

#sorted_listObject



13
14
15
# File 'lib/rake-file-content/dependency_list.rb', line 13

def sorted_list
  list.sort_by(&:first)
end