Class: Tagformula::Parser::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/tagformula/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tagname, needed) ⇒ Tag

Returns a new instance of Tag.



68
69
70
# File 'lib/tagformula/parser.rb', line 68

def initialize(tagname, needed)
	@tagname, @needed = tagname, needed
end

Instance Attribute Details

#neededObject (readonly)

Returns the value of attribute needed.



67
68
69
# File 'lib/tagformula/parser.rb', line 67

def needed
  @needed
end

#tagnameObject (readonly)

Returns the value of attribute tagname.



67
68
69
# File 'lib/tagformula/parser.rb', line 67

def tagname
  @tagname
end

Instance Method Details

#matches?(taglist) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
# File 'lib/tagformula/parser.rb', line 71

def matches?(taglist)
	case @tagname
	when 'true', 'false', 'yes', 'no'
		@needed
	else
		taglist.include?(@tagname) ? @needed : ! @needed
	end	
end