class Nanoc::Core::DependencyProps
@api private
Constants
- C_ATTRS
- C_RAW_CONTENT
TODO: Split
raw_content
for documents and collections
Attributes
attributes[R]
raw_content[R]
Public Class Methods
new(raw_content: false, attributes: false, compiled_content: false, path: false)
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 16 def initialize(raw_content: false, attributes: false, compiled_content: false, path: false) @compiled_content = compiled_content @path = path @attributes = case attributes when Set attributes when Enumerable Set.new(attributes) else attributes end @raw_content = case raw_content when Set raw_content when Enumerable Set.new(raw_content) else raw_content end end
Public Instance Methods
active()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 130 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
attributes?()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 74 def attributes? case @attributes when Enumerable @attributes.any? else @attributes end end
compiled_content?()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 84 def compiled_content? @compiled_content end
inspect()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 42 def inspect (+'').tap do |s| s << 'Props(' s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') s << ')' end end
merge(other)
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 94 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)
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 107 def merge_attributes(other) merge_prop(attributes, other.attributes) end
merge_prop(own, other)
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 111 def merge_prop(own, other) case own when true true when false other else case other when true true when false own else own + other end end end
merge_raw_content(other)
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 103 def merge_raw_content(other) merge_prop(raw_content, other.raw_content) end
path?()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 89 def path? @path end
raw_content?()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 64 def raw_content? case @raw_content when Enumerable @raw_content.any? else @raw_content end end
to_h()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 140 def to_h { raw_content: raw_content, attributes: attributes, compiled_content: compiled_content?, path: path?, } end
to_s()
click to toggle source
# File lib/nanoc/core/dependency_props.rb, line 54 def to_s (+'').tap do |s| s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') end end