Sha256: 30f09d9de781da8ee7ac44d68db808a686d7593cb6c46ff0d71da85925de3047

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

require 'uri'

require 'active_record'

module Murlsh

  # URL ActiveRecord.
  class Url < ActiveRecord::Base
    validates_format_of :url, :with => URI.regexp

    # Get the title of this url.
    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 with whitespace compressed and leading and trailing whitespace
    # stripped.
    def title_stripped; title.strip.gsub(/\s+/, ' '); end

    # Return true if this url has the same author as another url.
    def same_author?(other)
      other and other.email and other.name and
        email and name and email == other.email and name == other.name
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
murlsh-1.1.0 lib/murlsh/url.rb