Class: TextMarker::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/textmarker/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag = :span, background_color = :yellow, text_color = :black) ⇒ Tag

Returns a new instance of Tag.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/textmarker/tag.rb', line 7

def initialize(tag=:span, background_color=:yellow, text_color=:black)
  @valid_tags = get_valid_html_tags

  validate_tag(tag)
  validate_color(background_color)
  validate_color(text_color)

  @tag = tag
  @background_color = background_color
  @text_color = text_color

  @open_tag = generate_open_tag
  @close_tag = generate_close_tag
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



5
6
7
# File 'lib/textmarker/tag.rb', line 5

def background_color
  @background_color
end

#close_tagObject (readonly)

Returns the value of attribute close_tag.



5
6
7
# File 'lib/textmarker/tag.rb', line 5

def close_tag
  @close_tag
end

#open_tagObject (readonly)

Returns the value of attribute open_tag.



5
6
7
# File 'lib/textmarker/tag.rb', line 5

def open_tag
  @open_tag
end

#tagObject

Returns the value of attribute tag.



5
6
7
# File 'lib/textmarker/tag.rb', line 5

def tag
  @tag
end

#text_colorObject

Returns the value of attribute text_color.



5
6
7
# File 'lib/textmarker/tag.rb', line 5

def text_color
  @text_color
end

Instance Method Details

#to_sObject



22
23
24
# File 'lib/textmarker/tag.rb', line 22

def to_s
  generate_open_tag + generate_close_tag
end