Class: Murlsh::Url

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/murlsh/url.rb

Overview

URL ActiveRecord.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#user_supplied_titleObject Also known as: user_supplied_title?

Returns the value of attribute user_supplied_title.



45
46
47
# File 'lib/murlsh/url.rb', line 45

def user_supplied_title
  @user_supplied_title
end

Instance Method Details

#askObject



38
39
40
41
42
43
# File 'lib/murlsh/url.rb', line 38

def ask
  if !defined?(@ask) or @ask.to_s != url
    @ask = URI(url).extend(Murlsh::UriAsk)
  end
  @ask
end

#same_author?(other) ⇒ Boolean

Return true if this url has the same author as another url.

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/murlsh/url.rb', line 28

def same_author?(other)
  other and other.email and other.name and
    email and name and email == other.email and name == other.name
end

#same_thumbnail?(other) ⇒ Boolean

Return true if this url has the same thumbnail url as another url.

Returns:

  • (Boolean)


34
35
36
# File 'lib/murlsh/url.rb', line 34

def same_thumbnail?(other)
  other and thumbnail_url == other.thumbnail_url
end

#titleObject

Get the title of this url.



13
14
15
16
17
18
19
20
21
# File 'lib/murlsh/url.rb', line 13

def title
  ta = read_attribute(:title)
  ta = nil  if ta and ta.empty?
  
  ua = read_attribute(:url)
  ua = nil  if ua and ua.empty?

  ta || ua || 'title missing'
end

#title_strippedObject

Title with whitespace compressed and leading and trailing whitespace stripped.



25
# File 'lib/murlsh/url.rb', line 25

def title_stripped; title.to_s.strip.gsub(/\s+/, ' '); end