Class: ConfCtl::Generation::Unified
- Inherits:
-
Object
- Object
- ConfCtl::Generation::Unified
- Defined in:
- lib/confctl/generation/unified.rb
Instance Attribute Summary collapse
- #build_generation ⇒ Generation::Build
- #current ⇒ Boolean readonly
- #date ⇒ Time readonly
- #host ⇒ String readonly
- #host_generation ⇒ Generation::Host
- #id ⇒ Integer? readonly
- #name ⇒ String readonly
- #toplevel ⇒ String readonly
Instance Method Summary collapse
- #current_str ⇒ Object
- #destroy ⇒ Object
-
#includes?(gen) ⇒ Boolean
Determines whether ‘gen` can be wrapped by this object.
-
#initialize(host, build_generation: nil, host_generation: nil) ⇒ Unified
constructor
A new instance of Unified.
- #presence_str ⇒ Object
Constructor Details
#initialize(host, build_generation: nil, host_generation: nil) ⇒ Unified
Returns a new instance of Unified.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/confctl/generation/unified.rb', line 30 def initialize(host, build_generation: nil, host_generation: nil) @host = host @build_generation = build_generation @host_generation = host_generation @id = host_generation && host_generation.id if build_generation @name = build_generation.name @toplevel = build_generation.toplevel @date = build_generation.date @current ||= build_generation.current elsif host_generation @name = host_generation.approx_name @toplevel = host_generation.toplevel @date = host_generation.date @current ||= host_generation.current else raise ArgumentError, 'set build or host' end end |
Instance Attribute Details
#build_generation ⇒ Generation::Build
22 23 24 |
# File 'lib/confctl/generation/unified.rb', line 22 def build_generation @build_generation end |
#current ⇒ Boolean (readonly)
19 20 21 |
# File 'lib/confctl/generation/unified.rb', line 19 def current @current end |
#date ⇒ Time (readonly)
16 17 18 |
# File 'lib/confctl/generation/unified.rb', line 16 def date @date end |
#host ⇒ String (readonly)
4 5 6 |
# File 'lib/confctl/generation/unified.rb', line 4 def host @host end |
#host_generation ⇒ Generation::Host
25 26 27 |
# File 'lib/confctl/generation/unified.rb', line 25 def host_generation @host_generation end |
#id ⇒ Integer? (readonly)
10 11 12 |
# File 'lib/confctl/generation/unified.rb', line 10 def id @id end |
#name ⇒ String (readonly)
7 8 9 |
# File 'lib/confctl/generation/unified.rb', line 7 def name @name end |
#toplevel ⇒ String (readonly)
13 14 15 |
# File 'lib/confctl/generation/unified.rb', line 13 def toplevel @toplevel end |
Instance Method Details
#current_str ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/confctl/generation/unified.rb', line 86 def current_str build = build_generation && build_generation.current host = host_generation && host_generation.current if build && host 'build+host' elsif build 'build' elsif host 'host' end end |
#destroy ⇒ Object
111 112 113 114 115 |
# File 'lib/confctl/generation/unified.rb', line 111 def destroy build_generation.destroy if build_generation host_generation.destroy if host_generation true end |
#includes?(gen) ⇒ Boolean
Determines whether ‘gen` can be wrapped by this object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/confctl/generation/unified.rb', line 69 def includes?(gen) return false if host != gen.host || toplevel != gen.toplevel if build_generation && gen.is_a?(Generation::Build) build_generation.name == gen.name \ && build_generation.swpin_paths == gen.swpin_paths else true end end |
#presence_str ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/confctl/generation/unified.rb', line 99 def presence_str if build_generation && host_generation 'build+host' elsif build_generation 'build' elsif host_generation 'host' else raise 'programming error' end end |