Class: Jekyll::RpLogs::Tag
- Inherits:
-
Object
- Object
- Jekyll::RpLogs::Tag
- Defined in:
- lib/jekyll/rp_logs/rp_tags.rb
Overview
Holds tag information
Constant Summary collapse
- TYPES =
[:meta, :character, :general].freeze
- CHAR_FLAG =
/^char:(?<char_name>.*)/
- META_TAGS =
/(safe|questionable|explicit|canon|noncanon|complete|incomplete)/
- TYPE_CLASSES =
{ character: ["rp-tag-character"], meta: ["rp-tag-meta"], general: [] }.freeze
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.[](*args) ⇒ Object
Inspired by Hash, convert a list of strings to a list of Tags.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
- #classes ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name) ⇒ Tag
constructor
A new instance of Tag.
- #inspect ⇒ Object
- #to_liquid ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Tag
Returns a new instance of Tag.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 25 def initialize(name) # inspect types my_name = name.strip if CHAR_FLAG =~ my_name @name = $LAST_MATCH_INFO[:char_name] @type = :character else @name = my_name.downcase @type = @name =~ META_TAGS ? :meta : :general end @dir = name_to_dir(@name) end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
17 18 19 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 17 def dir @dir end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 17 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
17 18 19 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 17 def type @type end |
Class Method Details
Instance Method Details
#<=>(o) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 55 def <=>(o) if self.class == o.class && type == o.type name <=> o.name elsif type == :character -1 elsif o.type == :character 1 elsif type == :meta -1 elsif o.type == :meta 1 else nil end end |
#classes ⇒ Object
80 81 82 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 80 def classes TYPE_CLASSES[@type].join " " end |
#eql?(other) ⇒ Boolean
47 48 49 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 47 def eql?(other) self.class.equal?(other.class) && (name == other.name && type == other.type) end |
#hash ⇒ Object
51 52 53 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 51 def hash name.hash end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 71 def inspect self.class.name + "[" + @name + ", " + @dir + "]" end |
#to_liquid ⇒ Object
75 76 77 78 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 75 def to_liquid # Liquid wants a hash, not an object. { "name" => @name, "dir" => @dir, "classes" => classes } end |
#to_s ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/jekyll/rp_logs/rp_tags.rb', line 39 def to_s if type == :character "char:#{name}" else name end end |