Class: HotOrNot::CompareUrl
- Inherits:
-
Object
- Object
- HotOrNot::CompareUrl
- Defined in:
- lib/hot_or_not/compare_url.rb
Instance Attribute Summary collapse
-
#base_a ⇒ Object
readonly
Returns the value of attribute base_a.
-
#base_b ⇒ Object
readonly
Returns the value of attribute base_b.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(name, url, base_a, base_b, options = {}) ⇒ CompareUrl
constructor
A new instance of CompareUrl.
- #short_name ⇒ Object
- #side_a ⇒ Object
- #side_b ⇒ Object
Constructor Details
#initialize(name, url, base_a, base_b, options = {}) ⇒ CompareUrl
Returns a new instance of CompareUrl.
6 7 8 9 |
# File 'lib/hot_or_not/compare_url.rb', line 6 def initialize(name, url, base_a, base_b, ={}) @name, @url, @base_a, @base_b = name, url, base_a, base_b @options = end |
Instance Attribute Details
#base_a ⇒ Object (readonly)
Returns the value of attribute base_a.
4 5 6 |
# File 'lib/hot_or_not/compare_url.rb', line 4 def base_a @base_a end |
#base_b ⇒ Object (readonly)
Returns the value of attribute base_b.
4 5 6 |
# File 'lib/hot_or_not/compare_url.rb', line 4 def base_b @base_b end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/hot_or_not/compare_url.rb', line 4 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/hot_or_not/compare_url.rb', line 4 def url @url end |
Class Method Details
.load_from(filename) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hot_or_not/compare_url.rb', line 27 def self.load_from(filename) contents = YAML.load(run_erb(filename)).symbolize_keys! side_a, side_b, comparisons = contents.delete(:side_a), contents.delete(:side_b), contents.delete(:comparisons) raise "Your file is not in the proper format" unless side_a && side_b && comparisons comparisons.map do |h| h.symbolize_keys! name = h.delete :name url = h.delete :url = contents.merge h CompareUrl.new name, url, side_a, side_b, end end |
Instance Method Details
#full_name ⇒ Object
11 12 13 |
# File 'lib/hot_or_not/compare_url.rb', line 11 def full_name @name end |
#short_name ⇒ Object
15 16 17 |
# File 'lib/hot_or_not/compare_url.rb', line 15 def short_name @short_name ||= @name.underscore.gsub(/\s+/, '_') end |
#side_a ⇒ Object
19 20 21 |
# File 'lib/hot_or_not/compare_url.rb', line 19 def side_a @side_a ||= @base_a + @url end |
#side_b ⇒ Object
23 24 25 |
# File 'lib/hot_or_not/compare_url.rb', line 23 def side_b @side_b ||= @base_b + @url end |