Class: Jekyll::GitHubMetadata::Value
- Inherits:
-
Object
- Object
- Jekyll::GitHubMetadata::Value
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll-github-metadata/value.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Value
constructor
A new instance of Value.
- #render ⇒ Object
- #to_liquid ⇒ Object
Constructor Details
#initialize(*args) ⇒ Value
Returns a new instance of Value.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/jekyll-github-metadata/value.rb', line 13 def initialize(*args) case args.size when 1 @key = "{anonymous}" @value = args.first when 2 @key = args.first.to_s @value = args.last else raise ArgumentError, "#{args.size} args given but expected 1 or 2" end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/jekyll-github-metadata/value.rb', line 11 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/jekyll-github-metadata/value.rb', line 11 def value @value end |
Instance Method Details
#render ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/jekyll-github-metadata/value.rb', line 26 def render return @rendered if defined? @rendered @rendered = @value = Sanitizer.sanitize(call_or_value) rescue RuntimeError, NameError => e Jekyll::GitHubMetadata.log :error, "Error processing value '#{key}':" raise e end |
#to_liquid ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/jekyll-github-metadata/value.rb', line 35 def to_liquid case render when nil, true, false, Hash, String, Numeric, Array value else to_json end end |