Class: Nanoc::Core::DependencyProps Private
- Inherits:
-
Object
- Object
- Nanoc::Core::DependencyProps
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/dependency_props.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- C_RAW_CONTENT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
TODO: Split raw_content for documents and collections
C::Or[ C::SetOf[C::Or[String, Regexp]], C::ArrayOf[C::Or[String, Regexp]], C::Bool ]
- C_ATTR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
C::Or[ C::SetOf[ C::Or[ Symbol, # any value [Symbol, C::Any] # pair (specific value) ], ], C::ArrayOf[ C::Or[ Symbol, # any value [Symbol, C::Any] # pair (specific value) ]
- C_ARGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
C::KeywordArgs[ raw_content: C::Optional[C_RAW_CONTENT], attributes: C::Optional[C_ATTR], compiled_content: C::Optional[C::Bool]
Instance Attribute Summary collapse
- #attributes ⇒ Object readonly private
- #raw_content ⇒ Object readonly private
Instance Method Summary collapse
- #active ⇒ Object private
- #attribute_keys ⇒ Object private
- #attributes? ⇒ Boolean private
- #compiled_content? ⇒ Boolean private
-
#initialize(raw_content: false, attributes: false, compiled_content: false, path: false) ⇒ DependencyProps
constructor
private
A new instance of DependencyProps.
- #inspect ⇒ Object private
- #merge(other) ⇒ Object private
- #merge_attributes(other) ⇒ Object private
- #merge_prop(own, other) ⇒ Object private
- #merge_raw_content(other) ⇒ Object private
- #path? ⇒ Boolean private
- #raw_content? ⇒ Boolean private
- #to_h ⇒ Object private
- #to_s ⇒ Object private
Methods included from ContractsSupport
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(raw_content: false, attributes: false, compiled_content: false, path: false) ⇒ DependencyProps
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DependencyProps.
46 47 48 49 50 51 |
# File 'lib/nanoc/core/dependency_props.rb', line 46 def initialize(raw_content: false, attributes: false, compiled_content: false, path: false) @raw_content = raw_content @attributes = attributes @compiled_content = compiled_content @path = path end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/nanoc/core/dependency_props.rb', line 9 def attributes @attributes end |
#raw_content ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/nanoc/core/dependency_props.rb', line 10 def raw_content @raw_content end |
Instance Method Details
#active ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
159 160 161 162 163 164 165 166 |
# File 'lib/nanoc/core/dependency_props.rb', line 159 def active Set.new.tap do |pr| pr << :raw_content if raw_content? pr << :attributes if attributes? pr << :compiled_content if compiled_content? pr << :path if path? end end |
#attribute_keys ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
168 169 170 171 172 173 174 175 |
# File 'lib/nanoc/core/dependency_props.rb', line 168 def attribute_keys case @attributes when Enumerable @attributes.map { |a| a.is_a?(Array) ? a.first : a } else [] end end |
#attributes? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 106 107 108 109 110 |
# File 'lib/nanoc/core/dependency_props.rb', line 103 def attributes? case @attributes when Array, Set !@attributes.empty? else @attributes end end |
#compiled_content? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
113 114 115 |
# File 'lib/nanoc/core/dependency_props.rb', line 113 def compiled_content? @compiled_content end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/nanoc/core/dependency_props.rb', line 54 def inspect (+'').tap do |s| s << 'Props(' s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') if @raw_content.is_a?(Set) || @raw_content.is_a?(Array) @raw_content.each do |elem| s << '; raw_content(' s << elem.inspect s << ')' end end if @attributes.is_a?(Set) || @attributes.is_a?(Array) @attributes.each do |elem| s << '; attr(' s << elem.inspect s << ')' end end s << ')' end end |
#merge(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 126 127 128 129 130 |
# File 'lib/nanoc/core/dependency_props.rb', line 123 def merge(other) DependencyProps.new( raw_content: merge_raw_content(other), attributes: merge_attributes(other), compiled_content: compiled_content? || other.compiled_content?, path: path? || other.path?, ) end |
#merge_attributes(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
136 137 138 |
# File 'lib/nanoc/core/dependency_props.rb', line 136 def merge_attributes(other) merge_prop(attributes, other.attributes) end |
#merge_prop(own, other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/nanoc/core/dependency_props.rb', line 140 def merge_prop(own, other) case own when true true when false other else case other when true true when false own else Set.new(own + other) end end end |
#merge_raw_content(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
132 133 134 |
# File 'lib/nanoc/core/dependency_props.rb', line 132 def merge_raw_content(other) merge_prop(raw_content, other.raw_content) end |
#path? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
118 119 120 |
# File 'lib/nanoc/core/dependency_props.rb', line 118 def path? @path end |
#raw_content? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 96 97 98 99 100 |
# File 'lib/nanoc/core/dependency_props.rb', line 93 def raw_content? case @raw_content when Array, Set !@raw_content.empty? else @raw_content end end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
178 179 180 181 182 183 184 185 |
# File 'lib/nanoc/core/dependency_props.rb', line 178 def to_h { raw_content:, attributes:, compiled_content: compiled_content?, path: path?, } end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 86 87 88 89 90 |
# File 'lib/nanoc/core/dependency_props.rb', line 83 def to_s (+'').tap do |s| s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') end end |