Class: TrueURL

Inherits:
Object
  • Object
show all
Defined in:
lib/true_url.rb,
lib/true_url/context.rb,
lib/true_url/version.rb,
lib/true_url/strategy.rb,
lib/true_url/strategy/vimeo.rb,
lib/true_url/strategy/twitter.rb,
lib/true_url/strategy/youtube.rb,
lib/true_url/strategy/nicovideo.rb,
lib/true_url/strategy/dailymotion.rb
more...

Defined Under Namespace

Modules: Strategy Classes: Context

Constant Summary collapse

OPTIONS =
{
  scheme_override: nil, # Possible choices: "https", "http", nil (preserve scheme)
  fetch: true # Whether to fetch the URL
}.freeze
QUERY_VALUES_TO_REMOVE =
%w(
  utm_source
  utm_medium
  utm_term
  utm_content
  utm_campaign
  sms_ss
  awesm
  xtor
  PHPSESSID
).freeze
VERSION =
'0.0.3'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ TrueURL

Returns a new instance of TrueURL.

[View source]

26
27
28
29
30
# File 'lib/true_url.rb', line 26

def initialize(url, options = {})
  @context = TrueURL::Context.new(url, OPTIONS.merge(options))
  @strategies = TrueURL::Strategy.default_list
  @executed = false
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.


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

def context
  @context
end

#strategiesObject

Returns the value of attribute strategies.


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

def strategies
  @strategies
end

Instance Method Details

#attributesObject

[View source]

37
38
39
40
# File 'lib/true_url.rb', line 37

def attributes
  execute
  @context.attributes
end

#canonicalObject

[View source]

32
33
34
35
# File 'lib/true_url.rb', line 32

def canonical
  execute
  @context.working_url.to_s
end