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
- #kernel_version ⇒ String? 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.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/confctl/generation/unified.rb', line 33 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 @kernel_version = build_generation.kernel_version @current ||= build_generation.current elsif host_generation @name = host_generation.approx_name @toplevel = host_generation.toplevel @date = host_generation.date @kernel_version = host_generation.kernel_version @current ||= host_generation.current else raise ArgumentError, 'set build or host' end end |
Instance Attribute Details
#build_generation ⇒ Generation::Build
25 26 27 |
# File 'lib/confctl/generation/unified.rb', line 25 def build_generation @build_generation end |
#current ⇒ Boolean (readonly)
22 23 24 |
# File 'lib/confctl/generation/unified.rb', line 22 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
28 29 30 |
# File 'lib/confctl/generation/unified.rb', line 28 def host_generation @host_generation end |
#id ⇒ Integer? (readonly)
10 11 12 |
# File 'lib/confctl/generation/unified.rb', line 10 def id @id end |
#kernel_version ⇒ String? (readonly)
19 20 21 |
# File 'lib/confctl/generation/unified.rb', line 19 def kernel_version @kernel_version 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
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/confctl/generation/unified.rb', line 91 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
116 117 118 119 120 |
# File 'lib/confctl/generation/unified.rb', line 116 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
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/confctl/generation/unified.rb', line 74 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
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/confctl/generation/unified.rb', line 104 def presence_str if build_generation && host_generation 'build+host' elsif build_generation 'build' elsif host_generation 'host' else raise 'programming error' end end |