Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More refactoring to use component models
- Loading branch information
Andy Waite
committed
Feb 26, 2012
1 parent
17932d5
commit 6088da7
Showing
6 changed files
with
86 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Component | ||
class SubmissionListItem < Component::Base | ||
|
||
def initialize(root) | ||
@root = root | ||
end | ||
|
||
def name | ||
root.find('.name').text | ||
end | ||
|
||
def plus_votes | ||
root.find('.plus .value').text.to_i | ||
end | ||
|
||
def minus_votes | ||
root.find('.minus .value').text.to_i | ||
end | ||
|
||
def author_name | ||
root.find('.author-name').text | ||
end | ||
|
||
def buttons | ||
r = {} | ||
root.all('input').each do |input| | ||
r[input['value']] = input | ||
end | ||
r | ||
end | ||
|
||
def has_vote_button? | ||
root.has_css?("input[value='Vote']") | ||
end | ||
|
||
def vote_review | ||
sel = '.vote-review' | ||
root.find(sel).text.strip if root.has_css?(sel) | ||
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