Class: Murlsh::Url

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

Overview

URL ActiveRecord.

Instance Method Summary collapse

Instance Method Details

#askObject



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

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)


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

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

#titleObject

Get the title of this url.



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

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.



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

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