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
- BIT_PATTERN_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.
0x01- BIT_PATTERN_ATTRIBUTES =
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.
0x02- BIT_PATTERN_COMPILED_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.
0x04- BIT_PATTERN_PATH =
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.
0x08- 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
Class Method Summary collapse
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.
60 61 62 63 64 65 66 67 68 |
# File 'lib/nanoc/core/dependency_props.rb', line 60 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.
14 15 16 |
# File 'lib/nanoc/core/dependency_props.rb', line 14 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.
15 16 17 |
# File 'lib/nanoc/core/dependency_props.rb', line 15 def raw_content @raw_content end |
Class Method Details
.format_bit_pattern(pat) ⇒ 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.
50 51 52 53 54 55 56 57 |
# File 'lib/nanoc/core/dependency_props.rb', line 50 def self.format_bit_pattern(pat) (+'').tap do |s| s << (pat.nobits?(BIT_PATTERN_RAW_CONTENT) ? '_' : 'r') s << (pat.nobits?(BIT_PATTERN_ATTRIBUTES) ? '_' : 'a') s << (pat.nobits?(BIT_PATTERN_COMPILED_CONTENT) ? '_' : 'c') s << (pat.nobits?(BIT_PATTERN_PATH) ? '_' : 'p') end 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.
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/nanoc/core/dependency_props.rb', line 176 def active res = 0x00 res |= BIT_PATTERN_RAW_CONTENT if raw_content? res |= BIT_PATTERN_ATTRIBUTES if attributes? res |= BIT_PATTERN_COMPILED_CONTENT if compiled_content? res |= BIT_PATTERN_PATH if path? res 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.
187 188 189 190 191 192 193 194 |
# File 'lib/nanoc/core/dependency_props.rb', line 187 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.
120 121 122 123 124 125 126 127 |
# File 'lib/nanoc/core/dependency_props.rb', line 120 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.
130 131 132 |
# File 'lib/nanoc/core/dependency_props.rb', line 130 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.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/nanoc/core/dependency_props.rb', line 71 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.
140 141 142 143 144 145 146 147 |
# File 'lib/nanoc/core/dependency_props.rb', line 140 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.
153 154 155 |
# File 'lib/nanoc/core/dependency_props.rb', line 153 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.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/nanoc/core/dependency_props.rb', line 157 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.
149 150 151 |
# File 'lib/nanoc/core/dependency_props.rb', line 149 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.
135 136 137 |
# File 'lib/nanoc/core/dependency_props.rb', line 135 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.
110 111 112 113 114 115 116 117 |
# File 'lib/nanoc/core/dependency_props.rb', line 110 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.
197 198 199 200 201 202 203 204 |
# File 'lib/nanoc/core/dependency_props.rb', line 197 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.
100 101 102 103 104 105 106 107 |
# File 'lib/nanoc/core/dependency_props.rb', line 100 def to_s (+'').tap do |s| s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') end end |