Class: Craiggy::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/craiggy/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Post

Returns a new instance of Post.



6
7
8
9
10
11
12
13
14
# File 'lib/craiggy/post.rb', line 6

def initialize(page)
  post_params  = PostScraper.new(page).post_params
  @title       = post_params[:title]
  @image       = post_params[:image]
  @price       = post_params[:price]
  @location    = post_params[:location]
  @description = post_params[:description]
  @url         = post_params[:url]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/craiggy/post.rb', line 4

def description
  @description
end

#imageObject (readonly)

Returns the value of attribute image.



4
5
6
# File 'lib/craiggy/post.rb', line 4

def image
  @image
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/craiggy/post.rb', line 4

def location
  @location
end

#priceObject (readonly)

Returns the value of attribute price.



4
5
6
# File 'lib/craiggy/post.rb', line 4

def price
  @price
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/craiggy/post.rb', line 4

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/craiggy/post.rb', line 4

def url
  @url
end

Instance Method Details

#has_image?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/craiggy/post.rb', line 16

def has_image?
  image != ""
end