Class: ViewSpec::Subject
- Inherits:
-
Object
- Object
- ViewSpec::Subject
- Includes:
- Comparable
- Defined in:
- lib/view_spec/subject.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value) ⇒ Subject
constructor
A new instance of Subject.
- #to_identifier ⇒ Object
- #to_parameterized_path ⇒ Object
- #to_path ⇒ Object
- #to_short_identifier ⇒ Object
- #to_title ⇒ Object
Constructor Details
#initialize(value) ⇒ Subject
Returns a new instance of Subject.
9 10 11 |
# File 'lib/view_spec/subject.rb', line 9 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/view_spec/subject.rb', line 7 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/view_spec/subject.rb', line 25 def <=>(other) if other.is_a?(self.class) to_identifier.casecmp other.to_identifier else value <=> other end end |
#to_identifier ⇒ Object
17 18 19 |
# File 'lib/view_spec/subject.rb', line 17 def to_identifier @identifier ||= to_parameterized_path end |
#to_parameterized_path ⇒ Object
33 34 35 |
# File 'lib/view_spec/subject.rb', line 33 def to_parameterized_path to_path.parameterize end |
#to_path ⇒ Object
37 38 39 40 |
# File 'lib/view_spec/subject.rb', line 37 def to_path path = @value.to_s.underscore.gsub(/\s+/, "_").delete_suffix(".rb") path.gsub(/(_component|\/component)$/, "") end |
#to_short_identifier ⇒ Object
21 22 23 |
# File 'lib/view_spec/subject.rb', line 21 def to_short_identifier @short_identifier ||= to_identifier.split("/").last end |
#to_title ⇒ Object
13 14 15 |
# File 'lib/view_spec/subject.rb', line 13 def to_title @title ||= to_short_identifier.titleize end |