Class: Dato::Local::FieldType::Seo

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/local/field_type/seo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, description, image, twitter_card, repo) ⇒ Seo

Returns a new instance of Seo.



13
14
15
16
17
18
19
# File 'lib/dato/local/field_type/seo.rb', line 13

def initialize(title, description, image, twitter_card, repo)
  @title = title
  @description = description
  @image = image
  @repo = repo
  @twitter_card = twitter_card
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/dato/local/field_type/seo.rb', line 7

def description
  @description
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/dato/local/field_type/seo.rb', line 7

def title
  @title
end

#twitter_cardObject (readonly)

Returns the value of attribute twitter_card.



7
8
9
# File 'lib/dato/local/field_type/seo.rb', line 7

def twitter_card
  @twitter_card
end

Class Method Details

.parse(value, repo) ⇒ Object



9
10
11
# File 'lib/dato/local/field_type/seo.rb', line 9

def self.parse(value, repo)
  value && new(value[:title], value[:description], value[:image], value[:twitter_card], repo)
end

Instance Method Details

#imageObject



21
22
23
# File 'lib/dato/local/field_type/seo.rb', line 21

def image
  @image && UploadId.parse(@image, @repo)
end

#to_hash(*args) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/dato/local/field_type/seo.rb', line 25

def to_hash(*args)
  {
    title: title,
    description: description,
    image: image && image.to_hash(*args),
  }
end