Class: Jekyll::Assets::Extensible
- Inherits:
-
Object
- Object
- Jekyll::Assets::Extensible
- Defined in:
- lib/jekyll/assets/extensible.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#jekyll ⇒ Object
readonly
Returns the value of attribute jekyll.
Class Method Summary collapse
-
.for?(type:, args:) ⇒ true, false
– Allows you to use types to determine if this class fits.
-
.for_args?(args) ⇒ Boolean
–.
-
.for_type?(type) ⇒ Boolean
–.
-
.inherited(kls = nil) ⇒ Array<Class>
– Allows us to keep track of inheritence.
-
.internal! ⇒ Object
–.
-
.internal? ⇒ Boolean
–.
-
.requirements ⇒ Object
–.
Instance Method Summary collapse
-
#initialize(asset:, args:, ctx:) ⇒ Extensible
constructor
–.
Constructor Details
#initialize(asset:, args:, ctx:) ⇒ Extensible
–
15 16 17 18 19 20 21 |
# File 'lib/jekyll/assets/extensible.rb', line 15 def initialize(asset:, args:, ctx:) @args = args @env = ctx.registers[:site].sprockets @jekyll = @env.jekyll @asset = asset @ctx = ctx end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/jekyll/assets/extensible.rb', line 9 def args @args end |
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
11 12 13 |
# File 'lib/jekyll/assets/extensible.rb', line 11 def asset @asset end |
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
8 9 10 |
# File 'lib/jekyll/assets/extensible.rb', line 8 def ctx @ctx end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
12 13 14 |
# File 'lib/jekyll/assets/extensible.rb', line 12 def env @env end |
#jekyll ⇒ Object (readonly)
Returns the value of attribute jekyll.
10 11 12 |
# File 'lib/jekyll/assets/extensible.rb', line 10 def jekyll @jekyll end |
Class Method Details
.for?(type:, args:) ⇒ true, false
Note:
a type is a “content type”
– Allows you to use types to determine if this class fits. –
66 67 68 |
# File 'lib/jekyll/assets/extensible.rb', line 66 def self.for?(type:, args:) for_type?(type) && for_args?(args) end |
.for_args?(args) ⇒ Boolean
–
71 72 73 74 75 76 |
# File 'lib/jekyll/assets/extensible.rb', line 71 def self.for_args?(args) return true if arg_keys.empty? arg_keys.collect { |k| args.key?(k) }.none? do |k| k == false end end |
.for_type?(type) ⇒ Boolean
–
79 80 81 82 83 84 |
# File 'lib/jekyll/assets/extensible.rb', line 79 def self.for_type?(type) return true if content_types.empty? content_types.any? do |k| k.is_a?(Regexp) ? type =~ k : k.to_s == type.to_s end end |
.inherited(kls = nil) ⇒ Array<Class>
Note:
you should be using this when using extensible.
– Allows us to keep track of inheritence. –
29 30 31 32 33 |
# File 'lib/jekyll/assets/extensible.rb', line 29 def self.inherited(kls = nil) @inherited ||= [] return @inherited if kls.nil? @inherited << kls end |
.internal! ⇒ Object
–
46 47 48 49 50 |
# File 'lib/jekyll/assets/extensible.rb', line 46 def self.internal! if name.start_with?("Jekyll::Assets") requirements[:internal] = true end end |
.internal? ⇒ Boolean
–
53 54 55 56 57 |
# File 'lib/jekyll/assets/extensible.rb', line 53 def self.internal? requirements[ :internal ] end |
.requirements ⇒ Object
–
36 37 38 39 40 41 42 43 |
# File 'lib/jekyll/assets/extensible.rb', line 36 def self.requirements @requirements ||= { internal: false, args: [], types: [ # ] } end |