Class: TumblRb::Blog

Inherits:
Object
  • Object
show all
Defined in:
lib/tumbl_rb/blog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blog) ⇒ Blog

Returns a new instance of Blog.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tumbl_rb/blog.rb', line 5

def initialize(blog)
  case blog
  when String
    if blog.include?(".")
      @hostname = blog
      @username = blog.include?(".tumblr.com") ? blog.chomp(".tumblr.com") : nil
    else
      @hostname = "#{blog}.tumblr.com"
      @username = blog
    end
  when Hash
    @hostname = blog[:hostname] ||= blog[:blog]
    @username = blog[:username] ||= blog[:user]
  end
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



3
4
5
# File 'lib/tumbl_rb/blog.rb', line 3

def hostname
  @hostname
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/tumbl_rb/blog.rb', line 3

def username
  @username
end

Instance Method Details

#to_sString

Returns the hostname

Returns:

  • (String)


24
25
26
# File 'lib/tumbl_rb/blog.rb', line 24

def to_s
  @hostname
end

#urlString

Returns the url

Returns:

  • (String)


31
32
33
# File 'lib/tumbl_rb/blog.rb', line 31

def url
  "http://#{@hostname}"
end