Class: MetaTags::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_tags/configuration.rb,
sig/lib/meta_tags/configuration.rbs

Overview

MetaTags configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Initializes a new instance of Configuration class.



43
44
45
# File 'lib/meta_tags/configuration.rb', line 43

def initialize
  reset_defaults!
end

Instance Attribute Details

#description_limit ⇒ Integer

How many characters to truncate description to.

Returns:

  • (Integer)


13
14
15
# File 'lib/meta_tags/configuration.rb', line 13

def description_limit
  @description_limit
end

#keywords_limit ⇒ Integer

How many characters to truncate keywords to.

Returns:

  • (Integer)


16
17
18
# File 'lib/meta_tags/configuration.rb', line 16

def keywords_limit
  @keywords_limit
end

#keywords_lowercase ⇒ Boolean

Should keywords forced into lowercase?

Returns:

  • (Boolean)


22
23
24
# File 'lib/meta_tags/configuration.rb', line 22

def keywords_lowercase
  @keywords_lowercase
end

#keywords_separator ⇒ String

Keywords separator - a string to join keywords with.

Returns:

  • (String)


19
20
21
# File 'lib/meta_tags/configuration.rb', line 19

def keywords_separator
  @keywords_separator
end

#minify_output ⇒ Boolean

When true, the output will not include new line characters between meta tags. Default is false.

Returns:

  • (Boolean)


30
31
32
# File 'lib/meta_tags/configuration.rb', line 30

def minify_output
  @minify_output
end

#open_meta_tags ⇒ Boolean

Switches between open (<meta ... >) and closed (<meta ... />) meta tags. Default is true, which means "open".

Returns:

  • (Boolean)


26
27
28
# File 'lib/meta_tags/configuration.rb', line 26

def open_meta_tags
  @open_meta_tags
end

#property_tags ⇒ Array[String | Symbol] (readonly)

Custom meta tags that should use property attribute instead of name

  • an array of strings or symbols representing their names or name-prefixes.

Returns:

  • (Array[String | Symbol])


34
35
36
# File 'lib/meta_tags/configuration.rb', line 34

def property_tags
  @property_tags
end

Configure whenever Meta-Tags should skip canonicals on pages with noindex: true "shouldn't mix noindex & rel=canonical comes from: they're very contradictory pieces of information for us."

Returns:

  • (Boolean)


40
41
42
# File 'lib/meta_tags/configuration.rb', line 40

def skip_canonical_links_on_noindex
  @skip_canonical_links_on_noindex
end

#title_limit ⇒ Integer?

How many characters to truncate title to.

Returns:

  • (Integer, nil)


7
8
9
# File 'lib/meta_tags/configuration.rb', line 7

def title_limit
  @title_limit
end

#truncate_site_title_first ⇒ Boolean

Truncate site_title instead of title.

Returns:

  • (Boolean)


10
11
12
# File 'lib/meta_tags/configuration.rb', line 10

def truncate_site_title_first
  @truncate_site_title_first
end

Instance Method Details

#default_property_tags ⇒ Array[String | Symbol]

Returns:

  • (Array[String | Symbol])


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/meta_tags/configuration.rb', line 47

def default_property_tags
  [
    # App Link metadata https://developers.facebook.com/docs/applinks/metadata-reference
    'al',
    # Open Graph Markup https://developers.facebook.com/docs/sharing/webmasters#markup
    'fb',
    'og',
    # Facebook OpenGraph Object Types https://developers.facebook.com/docs/reference/opengraph
    # Note that these tags are used in a regex, so including e.g. 'restaurant' will affect
    # 'restaurant:category', 'restaurant:price_rating', and anything else under that namespace.
    'article',
    'book',
    'books',
    'business',
    'fitness',
    'game',
    'music',
    'place',
    'product',
    'profile',
    'restaurant',
    'video',
  ].freeze
end

#open_meta_tags? ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/meta_tags/configuration.rb', line 72

def open_meta_tags?
  !!open_meta_tags
end

#reset_defaults! ⇒ void

This method returns an undefined value.



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/meta_tags/configuration.rb', line 76

def reset_defaults!
  @title_limit = 70
  @truncate_site_title_first = false
  @description_limit = 300
  @keywords_limit = 255
  @keywords_separator = ', '
  @keywords_lowercase = true
  @property_tags = default_property_tags.dup
  @open_meta_tags = true
  @minify_output = false
  @skip_canonical_links_on_noindex = false
end