Class: RubyTerraform::Models::PathSet
- Inherits:
-
Object
- Object
- RubyTerraform::Models::PathSet
- Extended by:
- Forwardable
- Includes:
- ValueEquality
- Defined in:
- lib/ruby_terraform/models/path_set.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Class Method Summary collapse
Instance Method Summary collapse
- #add_paths_from(object) ⇒ Object
- #gaps ⇒ Object
-
#initialize(paths) ⇒ PathSet
constructor
A new instance of PathSet.
- #state ⇒ Object
Methods included from ValueEquality
Constructor Details
#initialize(paths) ⇒ PathSet
Returns a new instance of PathSet.
26 27 28 |
# File 'lib/ruby_terraform/models/path_set.rb', line 26 def initialize(paths) @paths = paths end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
24 25 26 |
# File 'lib/ruby_terraform/models/path_set.rb', line 24 def paths @paths end |
Class Method Details
.empty ⇒ Object
9 10 11 |
# File 'lib/ruby_terraform/models/path_set.rb', line 9 def empty new([]) end |
.extract_from(object) ⇒ Object
13 14 15 |
# File 'lib/ruby_terraform/models/path_set.rb', line 13 def extract_from(object) empty.add_paths_from(object) end |
Instance Method Details
#add_paths_from(object) ⇒ Object
30 31 32 |
# File 'lib/ruby_terraform/models/path_set.rb', line 30 def add_paths_from(object) self.class.new(paths + extract_paths_from(object)) end |
#gaps ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_terraform/models/path_set.rb', line 34 def gaps initial_context = { last: Path.new([]), complete: [] } result = paths.sort.inject(initial_context) do |acc, path| current_path = path last_path = acc[:last] missing_paths = determine_missing_paths(last_path, current_path) updated_paths = acc[:complete] + missing_paths { last: current_path, complete: updated_paths } end self.class.new(result[:complete]) end |
#state ⇒ Object
48 49 50 |
# File 'lib/ruby_terraform/models/path_set.rb', line 48 def state [paths] end |