Class: Crystal::Tag

Inherits:
Struct
  • Object
show all
Defined in:
lib/crystal/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/crystal/tag.rb', line 2

def name
  @name
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



2
3
4
# File 'lib/crystal/tag.rb', line 2

def value
  @value
end

Instance Method Details

#name_keyObject



3
4
5
# File 'lib/crystal/tag.rb', line 3

def name_key
  name.starts_with?('og:') ? :property : :name
end

#value_for_context(context) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/crystal/tag.rb', line 7

def value_for_context(context)
  case
  when asset?
    context.send(asset_path_method, value)
  when value.acts_like?(:time)
    value.iso8601
  when value.acts_like?(:date)
    value.strftime('%Y-%m-%d')
  else
    value
  end
end