Class: DataFormatter::Tag

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Tag

Returns a new instance of Tag.



8
9
10
11
12
13
14
# File 'lib/data_formatter/tag.rb', line 8

def initialize(args)
  @sanitizer = args.fetch(:sanitizer, Rack::Utils)
  @tag_name = args.fetch(:tag_name, "span")
  @content = args.fetch(:content)
  @surround = args.fetch(:surround, nil)
  @css_class = Array(args.fetch(:css_class, "")).compact.join(" ")
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/data_formatter/tag.rb', line 6

def content
  @content
end

#css_classObject (readonly)

Returns the value of attribute css_class.



6
7
8
# File 'lib/data_formatter/tag.rb', line 6

def css_class
  @css_class
end

#sanitizerObject (readonly)

Returns the value of attribute sanitizer.



6
7
8
# File 'lib/data_formatter/tag.rb', line 6

def sanitizer
  @sanitizer
end

#surroundObject (readonly)

Returns the value of attribute surround.



6
7
8
# File 'lib/data_formatter/tag.rb', line 6

def surround
  @surround
end

#tag_nameObject (readonly)

Returns the value of attribute tag_name.



6
7
8
# File 'lib/data_formatter/tag.rb', line 6

def tag_name
  @tag_name
end

Instance Method Details

#to_sObject



16
17
18
# File 'lib/data_formatter/tag.rb', line 16

def to_s
  [open_tag, safe_content, close_tag].join
end