Class: XRT::Statement::Tag
Instance Method Summary
collapse
Methods inherited from Block
#<<, #children, #closed?, #content, #inspect
#==, #auto_indent, #children, #contains_directive?, #content, #depth, #find_block_texts, #find_blocks, #find_blocks_with_directive, #include?, #inspect, #replace_child, #statements, #to_s
Constructor Details
#initialize(content) ⇒ Tag
Returns a new instance of Tag.
173
174
175
176
177
|
# File 'lib/xrt/statement.rb', line 173
def initialize content
@children = []
tag_start = XRT::Statement::TagStart.new content
self << tag_start
end
|
Instance Method Details
#tag_closing? ⇒ Boolean
202
203
204
|
# File 'lib/xrt/statement.rb', line 202
def tag_closing?
@children[1].content[0] == '/'
end
|
210
211
212
|
# File 'lib/xrt/statement.rb', line 210
def
@children[1].content[0] == '!'
end
|
#tag_independent? ⇒ Boolean
206
207
208
|
# File 'lib/xrt/statement.rb', line 206
def tag_independent?
@children[-2].content[-1] == '/'
end
|
#tag_name ⇒ Object
191
192
193
194
195
196
|
# File 'lib/xrt/statement.rb', line 191
def tag_name
return nil if @children.empty?
matched = @children[1].content.match(%r{\A/?(\w+)})
return nil unless matched
return matched[1].downcase
end
|
#tag_opening? ⇒ Boolean
198
199
200
|
# File 'lib/xrt/statement.rb', line 198
def tag_opening?
!tag_independent? && !tag_closing? && !tag_void_element? && !
end
|
#tag_raw_text_element? ⇒ Boolean
185
186
187
188
189
|
# File 'lib/xrt/statement.rb', line 185
def tag_raw_text_element?
raw_element_names = %w( script style )
raw_element_names.include?(self.tag_name)
end
|
#tag_void_element? ⇒ Boolean
179
180
181
182
183
|
# File 'lib/xrt/statement.rb', line 179
def tag_void_element?
void_element_names = %w( area base br col embed hr img input keygen link meta param source track wbr )
void_element_names.include?(self.tag_name)
end
|