forked from smudge/kickstarter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding new project_item concept for projects on profiles. updating sp…
…ecs and fixing a few other bugs.
- Loading branch information
Showing
7 changed files
with
124 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# encoding: utf-8 | ||
require_relative 'common' | ||
|
||
module Kickstarter | ||
class ProjectItem | ||
|
||
attr_reader :node | ||
|
||
def initialize(node) | ||
@node = node | ||
end | ||
|
||
def id | ||
@id ||= /\/projects\/([0-9]+)\/photo-carousel\.jpg/.match(thumbnail_url)[1].to_i | ||
end | ||
|
||
def name | ||
@name ||= node.css('.project_name').first.inner_html | ||
end | ||
|
||
def description | ||
@description ||= node.css('.project_description').first.inner_html | ||
end | ||
|
||
def url | ||
@url ||= node.attribute('href').to_s.split('?').first | ||
end | ||
|
||
def handle | ||
@handle ||= url.split('/projects/').last.gsub(/\/$/,"") | ||
end | ||
|
||
def image_url(style = :main) | ||
@image_url ||= thumbnail_url.split('?').first | ||
@image_url.gsub(/photo-carousel\.jpg/,"photo-#{style}.jpg") | ||
end | ||
|
||
|
||
def to_hash | ||
{ | ||
:id => id, | ||
:name => name, | ||
:handle => handle, | ||
:url => url, | ||
:description => description, | ||
:image_url => image_url | ||
} | ||
end | ||
|
||
def inspect | ||
to_hash.inspect | ||
end | ||
|
||
####################################################### | ||
private | ||
####################################################### | ||
|
||
#Use image_url instead. | ||
def thumbnail_url | ||
node.css('.project_thumbnail img').first.attribute('src').to_s | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters