Class: RakeContentFile::DependencyList
- Inherits:
-
Object
- Object
- RakeContentFile::DependencyList
- Defined in:
- lib/rake-file-content/dependency_list.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add(name, hash) ⇒ Object
-
#initialize ⇒ DependencyList
constructor
A new instance of DependencyList.
- #serialize ⇒ Object
- #sorted_list ⇒ Object
Constructor Details
#initialize ⇒ DependencyList
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
#list ⇒ Object
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 |
#serialize ⇒ Object
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_list ⇒ Object
13 14 15 |
# File 'lib/rake-file-content/dependency_list.rb', line 13 def sorted_list list.sort_by(&:first) end |