diff --git a/lib/oga/blacklist.rb b/lib/oga/blacklist.rb index f6013bb..4e28141 100644 --- a/lib/oga/blacklist.rb +++ b/lib/oga/blacklist.rb @@ -26,7 +26,7 @@ module Oga # @return [TrueClass|FalseClass] # def allow?(name) - return !names.include?(name) + !names.include?(name) end ## @@ -34,7 +34,7 @@ module Oga # @return [Oga::Blacklist] # def +(other) - return self.class.new(names + other.names) + self.class.new(names + other.names) end end # Blacklist end # Oga diff --git a/lib/oga/css/parser.rll b/lib/oga/css/parser.rll index a52f752..464f175 100644 --- a/lib/oga/css/parser.rll +++ b/lib/oga/css/parser.rll @@ -367,7 +367,7 @@ even # @return [AST::Node] # def current_element - return @current_element ||= s(:test, nil, '*') + @current_element ||= s(:test, nil, '*') end ## @@ -382,7 +382,7 @@ even def parse reset - return super + super end ## @@ -394,8 +394,6 @@ even # def on_test(namespace, name) @current_element = s(:test, namespace, name) - - return @current_element end ## @@ -406,7 +404,7 @@ even def on_pseudo_class(name, arg = nil) handler = "on_pseudo_class_#{name.gsub('-', '_')}" - return arg ? send(handler, arg) : send(handler) + arg ? send(handler, arg) : send(handler) end ## @@ -415,7 +413,7 @@ even # @return [AST::Node] # def on_pseudo_class_root - return s(:call, 'not', s(:axis, 'parent', s(:test, nil, '*'))) + s(:call, 'not', s(:axis, 'parent', s(:test, nil, '*'))) end ## @@ -425,7 +423,7 @@ even # @return [AST::Node] # def on_pseudo_class_nth_child(arg) - return generate_nth_child('preceding-sibling', arg) + generate_nth_child('preceding-sibling', arg) end ## @@ -435,7 +433,7 @@ even # @return [AST::Node] # def on_pseudo_class_nth_last_child(arg) - return generate_nth_child('following-sibling', arg) + generate_nth_child('following-sibling', arg) end ## @@ -445,7 +443,7 @@ even # @return [AST::Node] # def on_pseudo_class_nth_of_type(arg) - return generate_nth_child('preceding-sibling', arg, current_element) + generate_nth_child('preceding-sibling', arg, current_element) end ## @@ -455,7 +453,7 @@ even # @return [AST::Node] # def on_pseudo_class_nth_last_of_type(arg) - return generate_nth_child('following-sibling', arg, current_element) + generate_nth_child('following-sibling', arg, current_element) end ## @@ -464,7 +462,7 @@ even # @return [AST::Node] # def on_pseudo_class_first_child - return generate_no_siblings('preceding-sibling') + generate_no_siblings('preceding-sibling') end ## @@ -473,7 +471,7 @@ even # @return [AST::Node] # def on_pseudo_class_last_child - return generate_no_siblings('following-sibling') + generate_no_siblings('following-sibling') end ## @@ -482,7 +480,7 @@ even # @return [AST::Node] # def on_pseudo_class_first_of_type - return generate_no_siblings('preceding-sibling', current_element) + generate_no_siblings('preceding-sibling', current_element) end ## @@ -491,7 +489,7 @@ even # @return [AST::Node] # def on_pseudo_class_last_of_type - return generate_no_siblings('following-sibling', current_element) + generate_no_siblings('following-sibling', current_element) end ## @@ -500,7 +498,7 @@ even # @return [AST::Node] # def on_pseudo_class_only_child - return s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child) + s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child) end ## @@ -509,7 +507,7 @@ even # @return [AST::Node] # def on_pseudo_class_only_of_type - return s(:and, on_pseudo_class_first_of_type, on_pseudo_class_last_of_type) + s(:and, on_pseudo_class_first_of_type, on_pseudo_class_last_of_type) end ## @@ -518,7 +516,7 @@ even # @return [AST::Node] # def on_pseudo_class_empty - return s(:call, 'not', s(:axis, 'child', s(:type_test, 'node'))) + s(:call, 'not', s(:axis, 'child', s(:type_test, 'node'))) end ## @@ -529,7 +527,7 @@ even # @return [AST::Node] # def on_op_eq(attr, value) - return s(:eq, attr, value) + s(:eq, attr, value) end ## @@ -540,7 +538,7 @@ even # @return [AST::Node] # def on_op_space_in(attr, value) - return s( + s( :call, 'contains', s(:call, 'concat', s(:string, ' '), attr, s(:string, ' ')), @@ -556,7 +554,7 @@ even # @return [AST::Node] # def on_op_starts_with(attr, value) - return s(:call, 'starts-with', attr, value) + s(:call, 'starts-with', attr, value) end ## @@ -567,7 +565,7 @@ even # @return [AST::Node] # def on_op_ends_with(attr, value) - return s( + s( :eq, s( :call, @@ -596,7 +594,7 @@ even # @return [AST::Node] # def on_op_in(attr, value) - return s(:call, 'contains', attr, value) + s(:call, 'contains', attr, value) end ## @@ -607,7 +605,7 @@ even # @return [AST::Node] # def on_op_hyphen_in(attr, value) - return s( + s( :or, s(:eq, attr, value), s( @@ -662,7 +660,7 @@ even # @return [AST::Node] # def generate_no_siblings(axis, test = s(:test, nil, '*')) - return s(:eq, s(:call, 'count', s(:axis, axis, test)), s(:int, 0)) + s(:eq, s(:call, 'count', s(:axis, axis, test)), s(:int, 0)) end ## @@ -670,7 +668,7 @@ even # @return [TrueClass|FalseClass] # def int_node?(node) - return node.type.equal?(:int) + node.type.equal?(:int) end ## @@ -678,7 +676,7 @@ even # @return [TrueClass|FalseClass] # def non_positive_number?(node) - return node.children[0] <= 0 + node.children[0] <= 0 end ## @@ -686,7 +684,7 @@ even # @return [Symbol] # def step_comparison(node) - return node.children[0] >= 0 ? :gte : :lte + node.children[0] >= 0 ? :gte : :lte end ## @@ -706,6 +704,6 @@ even mod_val = s(:int, 1) end - return mod_val + mod_val end } diff --git a/lib/oga/entity_decoder.rb b/lib/oga/entity_decoder.rb index 24eaa4a..18d01be 100644 --- a/lib/oga/entity_decoder.rb +++ b/lib/oga/entity_decoder.rb @@ -4,7 +4,7 @@ module Oga # @see [decode] # def self.try_decode(input, html = false) - return input ? decode(input, html) : nil + input ? decode(input, html) : nil end ## @@ -15,7 +15,7 @@ module Oga def self.decode(input, html = false) decoder = html ? HTML::Entities : XML::Entities - return decoder.decode(input) + decoder.decode(input) end end # EntityDecoder end # Oga diff --git a/lib/oga/html/entities.rb b/lib/oga/html/entities.rb index 5423084..b67641a 100644 --- a/lib/oga/html/entities.rb +++ b/lib/oga/html/entities.rb @@ -2143,7 +2143,7 @@ module Oga # @see [decode] # def self.decode(input) - return XML::Entities.decode(input, DECODE_MAPPING) + XML::Entities.decode(input, DECODE_MAPPING) end end # Entities end # HTML diff --git a/lib/oga/lru.rb b/lib/oga/lru.rb index 50b85ac..a3d210a 100644 --- a/lib/oga/lru.rb +++ b/lib/oga/lru.rb @@ -50,7 +50,7 @@ module Oga # @return [Fixnum] # def maximum - return synchronize { @maximum } + synchronize { @maximum } end ## @@ -60,7 +60,7 @@ module Oga # @return [Mixed] # def [](key) - return synchronize { @cache[key] } + synchronize { @cache[key] } end ## @@ -90,14 +90,14 @@ module Oga # @return [Mixed] # def get_or_set(key) - return synchronize { self[key] ||= yield } + synchronize { self[key] ||= yield } end ## # @return [Array] # def keys - return synchronize { @keys } + synchronize { @keys } end ## @@ -105,7 +105,7 @@ module Oga # @return [TrueClass|FalseClass] # def key?(key) - return synchronize { @cache.key?(key) } + synchronize { @cache.key?(key) } end ## @@ -122,7 +122,7 @@ module Oga # @return [Fixnum] # def size - return synchronize { @cache.size } + synchronize { @cache.size } end alias_method :length, :size diff --git a/lib/oga/oga.rb b/lib/oga/oga.rb index b7feda2..dc0f502 100644 --- a/lib/oga/oga.rb +++ b/lib/oga/oga.rb @@ -10,7 +10,7 @@ module Oga # @return [Oga::XML::Document] # def self.parse_xml(xml, options = {}) - return XML::Parser.new(xml, options).parse + XML::Parser.new(xml, options).parse end ## @@ -24,7 +24,7 @@ module Oga # @return [Oga::XML::Document] # def self.parse_html(html, options = {}) - return HTML::Parser.new(html, options).parse + HTML::Parser.new(html, options).parse end ## diff --git a/lib/oga/whitelist.rb b/lib/oga/whitelist.rb index 8a76670..8ffe706 100644 --- a/lib/oga/whitelist.rb +++ b/lib/oga/whitelist.rb @@ -7,14 +7,14 @@ module Oga # @return [TrueClass|FalseClass] # def allow?(name) - return names.include?(name) + names.include?(name) end ## # @return [Oga::Blacklist] # def to_blacklist - return Blacklist.new(names) + Blacklist.new(names) end end # Whitelist end # Oga diff --git a/lib/oga/xml/attribute.rb b/lib/oga/xml/attribute.rb index 7de6fd7..1aa87fe 100644 --- a/lib/oga/xml/attribute.rb +++ b/lib/oga/xml/attribute.rb @@ -57,7 +57,7 @@ module Oga end end - return @namespace + @namespace end ## @@ -79,14 +79,14 @@ module Oga @decoded = true end - return @value + @value end ## # @return [String] # def text - return value.to_s + value.to_s end alias_method :to_s, :text @@ -103,7 +103,7 @@ module Oga enc_value = value ? Entities.encode(value) : nil - return %Q(#{full_name}="#{enc_value}") + %Q(#{full_name}="#{enc_value}") end ## @@ -120,7 +120,7 @@ module Oga end end - return "Attribute(#{segments.join(' ')})" + "Attribute(#{segments.join(' ')})" end private @@ -129,7 +129,7 @@ module Oga # @return [TrueClass|FalseClass] # def html? - return !!@element && @element.html? + !!@element && @element.html? end end # Attribute end # XML diff --git a/lib/oga/xml/cdata.rb b/lib/oga/xml/cdata.rb index f830f1c..e3a134b 100644 --- a/lib/oga/xml/cdata.rb +++ b/lib/oga/xml/cdata.rb @@ -10,7 +10,7 @@ module Oga # @return [String] # def to_xml - return "" + "" end end # Cdata end # XML diff --git a/lib/oga/xml/character_node.rb b/lib/oga/xml/character_node.rb index 7bcf180..3661bde 100644 --- a/lib/oga/xml/character_node.rb +++ b/lib/oga/xml/character_node.rb @@ -23,14 +23,14 @@ module Oga # @return [String] # def to_xml - return text.to_s + text.to_s end ## # @return [String] # def inspect - return "#{self.class.to_s.split('::').last}(#{text.inspect})" + "#{self.class.to_s.split('::').last}(#{text.inspect})" end end # CharacterNode end # XML diff --git a/lib/oga/xml/comment.rb b/lib/oga/xml/comment.rb index c1f237b..55cada5 100644 --- a/lib/oga/xml/comment.rb +++ b/lib/oga/xml/comment.rb @@ -10,7 +10,7 @@ module Oga # @return [String] # def to_xml - return "" + "" end end # Comment end # XML diff --git a/lib/oga/xml/doctype.rb b/lib/oga/xml/doctype.rb index e83f6d6..3b39fa1 100644 --- a/lib/oga/xml/doctype.rb +++ b/lib/oga/xml/doctype.rb @@ -56,7 +56,7 @@ module Oga segments << %Q{ "#{system_id}"} if system_id segments << " [#{inline_rules}]" if inline_rules - return segments + '>' + segments + '>' end ## @@ -75,7 +75,7 @@ module Oga end end - return "Doctype(#{segments.join(' ')})" + "Doctype(#{segments.join(' ')})" end end # Doctype end # XML diff --git a/lib/oga/xml/document.rb b/lib/oga/xml/document.rb index 044af01..55792d4 100644 --- a/lib/oga/xml/document.rb +++ b/lib/oga/xml/document.rb @@ -38,7 +38,7 @@ module Oga # @return [Oga::XML::NodeSet] # def children - return @children ||= NodeSet.new([], self) + @children ||= NodeSet.new([], self) end ## @@ -70,14 +70,14 @@ module Oga xml = xml_declaration.to_xml + "\n" + xml.strip end - return xml + xml end ## # @return [TrueClass|FalseClass] # def html? - return type.equal?(:html) + type.equal?(:html) end ## @@ -97,7 +97,7 @@ module Oga end end - return <<-EOF.strip + <<-EOF.strip Document( #{segments.join("\n ")} ) diff --git a/lib/oga/xml/element.rb b/lib/oga/xml/element.rb index a847f9d..da9cbcf 100644 --- a/lib/oga/xml/element.rb +++ b/lib/oga/xml/element.rb @@ -95,7 +95,7 @@ module Oga def get(name) found = attribute(name) - return found ? found.value : nil + found ? found.value : nil end ## @@ -165,7 +165,7 @@ module Oga @namespace = available[namespace_name] || available[XMLNS_PREFIX] end - return @namespace + @namespace end ## @@ -175,7 +175,7 @@ module Oga # @return [Hash] # def namespaces - return html? ? {} : @namespaces + html? ? {} : @namespaces end ## @@ -185,7 +185,7 @@ module Oga # @return [TrueClass|FalseClass] # def default_namespace? - return namespace == DEFAULT_NAMESPACE || namespace.nil? + namespace == DEFAULT_NAMESPACE || namespace.nil? end ## @@ -194,7 +194,7 @@ module Oga # @return [String] # def text - return children.text + children.text end ## @@ -209,7 +209,7 @@ module Oga text << node.text end - return text + text end ## @@ -225,7 +225,7 @@ module Oga nodes << child if child.is_a?(Text) end - return nodes + nodes end ## @@ -280,7 +280,7 @@ module Oga segments << "#{attr}: #{value.inspect}" end - return "Element(#{segments.join(' ')})" + "Element(#{segments.join(' ')})" end ## @@ -329,7 +329,7 @@ module Oga end end - return @available_namespaces + @available_namespaces end ## @@ -346,7 +346,7 @@ module Oga self_closing = false end - return self_closing + self_closing end ## @@ -401,7 +401,7 @@ module Oga def split_name(name) segments = name.to_s.split(':') - return segments.pop, segments.pop + [segments.pop, segments.pop] end ## @@ -421,7 +421,7 @@ module Oga ns_matches = true end - return name_matches && ns_matches + name_matches && ns_matches end end # Element end # XML diff --git a/lib/oga/xml/entities.rb b/lib/oga/xml/entities.rb index 63cd974..c2000ff 100644 --- a/lib/oga/xml/entities.rb +++ b/lib/oga/xml/entities.rb @@ -74,7 +74,7 @@ module Oga end end - return input + input end ## @@ -85,7 +85,7 @@ module Oga # @return [String] # def self.encode(input, mapping = ENCODE_MAPPING) - return input.gsub(ENCODE_REGEXP, mapping) + input.gsub(ENCODE_REGEXP, mapping) end end # Entities end # XML diff --git a/lib/oga/xml/lexer.rb b/lib/oga/xml/lexer.rb index 32467e1..900eecf 100644 --- a/lib/oga/xml/lexer.rb +++ b/lib/oga/xml/lexer.rb @@ -175,7 +175,7 @@ module Oga reset - return tokens + tokens end ## @@ -216,28 +216,28 @@ module Oga # @return [TrueClass|FalseClass] # def html? - return @html == true + @html == true end ## # @return [TrueClass|FalseClass] # def strict? - return @strict + @strict end ## # @return [TrueClass|FalseClass] # def html_script? - return html? && current_element == HTML_SCRIPT + html? && current_element == HTML_SCRIPT end ## # @return [TrueClass|FalseClass] # def html_style? - return html? && current_element == HTML_STYLE + html? && current_element == HTML_STYLE end private @@ -269,7 +269,7 @@ module Oga # @return [String] # def current_element - return @elements.last + @elements.last end ## diff --git a/lib/oga/xml/namespace.rb b/lib/oga/xml/namespace.rb index dc6317d..a1cf56b 100644 --- a/lib/oga/xml/namespace.rb +++ b/lib/oga/xml/namespace.rb @@ -26,14 +26,14 @@ module Oga # @return [String] # def to_s - return name.to_s + name.to_s end ## # @return [String] # def inspect - return "Namespace(name: #{name.inspect} uri: #{uri.inspect})" + "Namespace(name: #{name.inspect} uri: #{uri.inspect})" end ## @@ -41,7 +41,7 @@ module Oga # @return [TrueClass|FalseClass] # def ==(other) - return other.is_a?(self.class) && name == other.name && uri == other.uri + other.is_a?(self.class) && name == other.name && uri == other.uri end end # Namespace end # XML diff --git a/lib/oga/xml/node.rb b/lib/oga/xml/node.rb index defaa16..1ab9fdc 100644 --- a/lib/oga/xml/node.rb +++ b/lib/oga/xml/node.rb @@ -40,7 +40,7 @@ module Oga # @return [Oga::XML::NodeSet] # def children - return @children ||= NodeSet.new([], self) + @children ||= NodeSet.new([], self) end ## @@ -63,7 +63,7 @@ module Oga # @return [Oga::XML::Node] # def parent - return node_set ? node_set.owner : nil + node_set ? node_set.owner : nil end ## @@ -74,7 +74,7 @@ module Oga def previous index = node_set.index(self) - 1 - return index >= 0 ? node_set[index] : nil + index >= 0 ? node_set[index] : nil end ## @@ -86,7 +86,7 @@ module Oga index = node_set.index(self) + 1 length = node_set.length - return index <= length ? node_set[index] : nil + index <= length ? node_set[index] : nil end ## @@ -140,7 +140,7 @@ module Oga @root_node = node end - return @root_node + @root_node end ## @@ -184,14 +184,14 @@ module Oga @html_p = root.is_a?(Document) && root.html? end - return @html_p + @html_p end ## # @return [TrueClass|FalseClass] # def xml? - return !html? + !html? end end # Element end # XML diff --git a/lib/oga/xml/node_set.rb b/lib/oga/xml/node_set.rb index 6fd7662..78213ed 100644 --- a/lib/oga/xml/node_set.rb +++ b/lib/oga/xml/node_set.rb @@ -63,7 +63,7 @@ module Oga # @return [Oga::XML::Node] # def last - return @nodes[-1] + @nodes[-1] end ## @@ -72,7 +72,7 @@ module Oga # @return [TrueClass|FalseClass] # def empty? - return @nodes.empty? + @nodes.empty? end ## @@ -81,7 +81,7 @@ module Oga # @return [Fixnum] # def length - return @nodes.length + @nodes.length end alias_method :count, :length @@ -94,7 +94,7 @@ module Oga # @return [Fixnum] # def index(node) - return @nodes.index(node) + @nodes.index(node) end ## @@ -135,7 +135,7 @@ module Oga remove_ownership(node) - return node + node end ## @@ -148,7 +148,7 @@ module Oga remove_ownership(node) - return node + node end ## @@ -172,7 +172,7 @@ module Oga # @return [Oga::XML::Node] # def [](index) - return @nodes[index] + @nodes[index] end ## @@ -181,7 +181,7 @@ module Oga # @return [Array] # def to_a - return @nodes + @nodes end ## @@ -192,7 +192,7 @@ module Oga # @return [Oga::XML::NodeSet] # def +(other) - return self.class.new(to_a | other.to_a) + self.class.new(to_a | other.to_a) end ## @@ -202,7 +202,7 @@ module Oga # @param [Oga::XML::NodeSet] other # def ==(other) - return other.is_a?(NodeSet) && other.equal_nodes?(@nodes) + other.is_a?(NodeSet) && other.equal_nodes?(@nodes) end ## @@ -214,7 +214,7 @@ module Oga # @param [Array] nodes # def equal_nodes?(nodes) - return @nodes == nodes + @nodes == nodes end ## @@ -259,7 +259,7 @@ module Oga remove_ownership(removed) if removed - return removed + removed end ## @@ -277,7 +277,7 @@ module Oga end end - return values + values end alias_method :attr, :attribute @@ -296,7 +296,7 @@ module Oga end end - return text + text end ## @@ -305,7 +305,7 @@ module Oga def inspect values = @nodes.map(&:inspect).join(', ') - return "NodeSet(#{values})" + "NodeSet(#{values})" end private diff --git a/lib/oga/xml/processing_instruction.rb b/lib/oga/xml/processing_instruction.rb index e334360..925d4c9 100644 --- a/lib/oga/xml/processing_instruction.rb +++ b/lib/oga/xml/processing_instruction.rb @@ -23,14 +23,14 @@ module Oga # @return [String] # def to_xml - return "" + "" end ## # @return [String] # def inspect - return "ProcessingInstruction(name: #{name.inspect} text: #{text.inspect})" + "ProcessingInstruction(name: #{name.inspect} text: #{text.inspect})" end end # ProcessingInstruction end # XML diff --git a/lib/oga/xml/querying.rb b/lib/oga/xml/querying.rb index ff9fc03..0031e66 100644 --- a/lib/oga/xml/querying.rb +++ b/lib/oga/xml/querying.rb @@ -13,7 +13,7 @@ module Oga # @see [Oga::XPath::Evaluator#initialize] # def xpath(expression, variables = {}) - return XPath::Evaluator.new(self, variables).evaluate(expression) + XPath::Evaluator.new(self, variables).evaluate(expression) end ## @@ -25,7 +25,7 @@ module Oga def at_xpath(*args) result = xpath(*args) - return result.is_a?(XML::NodeSet) ? result.first : result + result.is_a?(XML::NodeSet) ? result.first : result end ## @@ -37,7 +37,7 @@ module Oga def css(expression) ast = CSS::Parser.parse_with_cache(expression) - return XPath::Evaluator.new(self).evaluate_ast(ast) + XPath::Evaluator.new(self).evaluate_ast(ast) end ## @@ -49,7 +49,7 @@ module Oga def at_css(*args) result = css(*args) - return result.is_a?(XML::NodeSet) ? result.first : result + result.is_a?(XML::NodeSet) ? result.first : result end end # Querying end # XML diff --git a/lib/oga/xml/sax_parser.rb b/lib/oga/xml/sax_parser.rb index 2d4033b..16e97d8 100644 --- a/lib/oga/xml/sax_parser.rb +++ b/lib/oga/xml/sax_parser.rb @@ -99,7 +99,7 @@ module Oga def on_element(namespace, name, attrs = []) run_callback(:on_element, namespace, name, attrs) - return namespace, name + [namespace, name] end ## @@ -132,7 +132,7 @@ module Oga value = EntityDecoder.try_decode(value, @lexer.html?) end - return {key => value} + {key => value} end ## @@ -153,7 +153,7 @@ module Oga pair.each { |key, value| merged[key] = value } end - return merged + merged end ## @@ -177,7 +177,7 @@ module Oga # @return [TrueClass|FalseClass] # def inside_literal_html? - return @lexer.html_script? || @lexer.html_style? + @lexer.html_script? || @lexer.html_style? end ## diff --git a/lib/oga/xml/text.rb b/lib/oga/xml/text.rb index a6bbb50..9c5b9be 100644 --- a/lib/oga/xml/text.rb +++ b/lib/oga/xml/text.rb @@ -31,7 +31,7 @@ module Oga @decoded = true end - return @text + @text end ## @@ -40,7 +40,7 @@ module Oga def to_xml return super if inside_literal_html? - return Entities.encode(super) + Entities.encode(super) end private @@ -49,7 +49,7 @@ module Oga # @return [TrueClass|FalseClass] # def decode_entities? - return !@decoded && !inside_literal_html? + !@decoded && !inside_literal_html? end ## @@ -58,7 +58,7 @@ module Oga def inside_literal_html? node = parent - return node.is_a?(Element) && html? && + node.is_a?(Element) && html? && Lexer::LITERAL_HTML_ELEMENTS.allow?(node.name) end end # Text diff --git a/lib/oga/xml/xml_declaration.rb b/lib/oga/xml/xml_declaration.rb index f930cc3..b112cff 100644 --- a/lib/oga/xml/xml_declaration.rb +++ b/lib/oga/xml/xml_declaration.rb @@ -41,7 +41,7 @@ module Oga pairs << %Q{#{getter}="#{value}"} if value end - return "" + "" end ## @@ -58,7 +58,7 @@ module Oga end end - return "XmlDeclaration(#{segments.join(' ')})" + "XmlDeclaration(#{segments.join(' ')})" end end # XmlDeclaration end # XML diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index f6dd359..dee0045 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -89,7 +89,7 @@ module Oga def evaluate(string) ast = Parser.parse_with_cache(string) - return evaluate_ast(ast) + evaluate_ast(ast) end ## @@ -101,7 +101,7 @@ module Oga def evaluate_ast(ast) context = XML::NodeSet.new([@document]) - return process(ast, context) + process(ast, context) end ## @@ -119,7 +119,7 @@ module Oga def process(ast_node, context) handler = "on_#{ast_node.type}" - return send(handler, ast_node, context) + send(handler, ast_node, context) end ## @@ -137,7 +137,7 @@ module Oga end # If the expression is just "/" we'll just return the current context. - return ast_node.children.empty? ? context : on_path(ast_node, context) + ast_node.children.empty? ? context : on_path(ast_node, context) end ## @@ -164,7 +164,7 @@ module Oga end end - return nodes + nodes end ## @@ -181,7 +181,7 @@ module Oga nodes << xml_node if node_matches?(xml_node, ast_node) end - return nodes + nodes end ## @@ -221,7 +221,7 @@ module Oga end end - return final_nodes + final_nodes end ## @@ -238,7 +238,7 @@ module Oga handler = name.gsub('-', '_') - return send("on_axis_#{handler}", test, context) + send("on_axis_#{handler}", test, context) end ## @@ -266,7 +266,7 @@ module Oga end end - return nodes + nodes end ## @@ -288,7 +288,7 @@ module Oga end end - return nodes + nodes end ## @@ -312,7 +312,7 @@ module Oga nodes += on_test(ast_node, xml_node.attributes) end - return nodes + nodes end ## @@ -324,7 +324,7 @@ module Oga # @return [Oga::XML::NodeSet] # def on_axis_child(ast_node, context) - return process(ast_node, child_nodes(context)) + process(ast_node, child_nodes(context)) end ## @@ -344,7 +344,7 @@ module Oga end end - return nodes + nodes end ## @@ -359,7 +359,7 @@ module Oga nodes.concat(on_axis_descendant(ast_node, context)) - return nodes + nodes end ## @@ -390,7 +390,7 @@ module Oga end end - return nodes + nodes end ## @@ -428,7 +428,7 @@ module Oga end end - return nodes + nodes end ## @@ -449,7 +449,7 @@ module Oga nodes << parent if node_matches?(parent, ast_node) end - return nodes + nodes end ## @@ -476,7 +476,7 @@ module Oga end end - return nodes + nodes end ## @@ -504,7 +504,7 @@ module Oga end end - return nodes + nodes end ## @@ -521,7 +521,7 @@ module Oga nodes << context_node if node_matches?(context_node, ast_node) end - return nodes + nodes end ## @@ -545,7 +545,7 @@ module Oga end end - return nodes + nodes end ## @@ -560,7 +560,7 @@ module Oga handler = name.gsub('-', '_') - return send("on_type_test_#{handler}", test, context) + send("on_type_test_#{handler}", test, context) end ## @@ -579,7 +579,7 @@ module Oga end end - return nodes + nodes end ## @@ -596,7 +596,7 @@ module Oga nodes << node if node.is_a?(XML::Text) end - return nodes + nodes end ## @@ -613,7 +613,7 @@ module Oga nodes << node if node.is_a?(XML::Comment) end - return nodes + nodes end ## @@ -631,7 +631,7 @@ module Oga nodes << node if node.is_a?(XML::ProcessingInstruction) end - return nodes + nodes end ## @@ -645,7 +645,7 @@ module Oga def on_pipe(ast_node, context) left, right = *ast_node.children - return process(left, context) + process(right, context) + process(left, context) + process(right, context) end ## @@ -662,7 +662,7 @@ module Oga def on_and(ast_node, context) left, right = *ast_node.children - return on_call_boolean(context, left) && on_call_boolean(context, right) + on_call_boolean(context, left) && on_call_boolean(context, right) end ## @@ -679,7 +679,7 @@ module Oga def on_or(ast_node, context) left, right = *ast_node.children - return on_call_boolean(context, left) || on_call_boolean(context, right) + on_call_boolean(context, left) || on_call_boolean(context, right) end ## @@ -695,7 +695,7 @@ module Oga def on_add(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) + on_call_number(context, right) + on_call_number(context, left) + on_call_number(context, right) end ## @@ -711,7 +711,7 @@ module Oga def on_div(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) / on_call_number(context, right) + on_call_number(context, left) / on_call_number(context, right) end ## @@ -727,7 +727,7 @@ module Oga def on_mod(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) % on_call_number(context, right) + on_call_number(context, left) % on_call_number(context, right) end ## @@ -743,7 +743,7 @@ module Oga def on_mul(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) * on_call_number(context, right) + on_call_number(context, left) * on_call_number(context, right) end ## @@ -759,7 +759,7 @@ module Oga def on_sub(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) - on_call_number(context, right) + on_call_number(context, left) - on_call_number(context, right) end ## @@ -795,7 +795,7 @@ module Oga right = to_string(right) end - return left == right + left == right end ## @@ -807,7 +807,7 @@ module Oga # @see [#on_eq] # def on_neq(ast_node, context) - return !on_eq(ast_node, context) + !on_eq(ast_node, context) end ## @@ -823,7 +823,7 @@ module Oga def on_lt(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) < on_call_number(context, right) + on_call_number(context, left) < on_call_number(context, right) end ## @@ -839,7 +839,7 @@ module Oga def on_gt(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) > on_call_number(context, right) + on_call_number(context, left) > on_call_number(context, right) end ## @@ -856,7 +856,7 @@ module Oga def on_lte(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) <= on_call_number(context, right) + on_call_number(context, left) <= on_call_number(context, right) end ## @@ -873,7 +873,7 @@ module Oga def on_gte(ast_node, context) left, right = *ast_node.children - return on_call_number(context, left) >= on_call_number(context, right) + on_call_number(context, left) >= on_call_number(context, right) end ## @@ -894,7 +894,7 @@ module Oga handler = name.gsub('-', '_') - return send("on_call_#{handler}", context, *args) + send("on_call_#{handler}", context, *args) end ## @@ -906,7 +906,7 @@ module Oga # def on_call_last(context) # XPath uses indexes 1 to N instead of 0 to N. - return current_node_set.length.to_f + current_node_set.length.to_f end ## @@ -919,7 +919,7 @@ module Oga def on_call_position(context) index = current_node_set.index(context.first) + 1 - return index.to_f + index.to_f end ## @@ -937,7 +937,7 @@ module Oga raise TypeError, 'count() can only operate on NodeSet instances' end - return retval.length.to_f + retval.length.to_f end ## @@ -977,7 +977,7 @@ module Oga end end - return nodes + nodes end ## @@ -995,7 +995,7 @@ module Oga def on_call_local_name(context, expression = nil) node = function_node(context, expression) - return node.respond_to?(:name) ? node.name : '' + node.respond_to?(:name) ? node.name : '' end ## @@ -1113,7 +1113,7 @@ module Oga convert = context.first.text end - return to_float(convert) + to_float(convert) end ## @@ -1135,7 +1135,7 @@ module Oga retval << on_call_string(context, arg) end - return retval + retval end ## @@ -1157,7 +1157,7 @@ module Oga needle_str = on_call_string(context, needle) # https://github.com/jruby/jruby/issues/1923 - return needle_str.empty? || haystack_str.start_with?(needle_str) + needle_str.empty? || haystack_str.start_with?(needle_str) end ## @@ -1178,7 +1178,7 @@ module Oga haystack_str = on_call_string(context, haystack) needle_str = on_call_string(context, needle) - return haystack_str.include?(needle_str) + haystack_str.include?(needle_str) end ## @@ -1202,7 +1202,7 @@ module Oga before, sep, after = haystack_str.partition(needle_str) - return sep.empty? ? sep : before + sep.empty? ? sep : before end ## @@ -1226,7 +1226,7 @@ module Oga before, sep, after = haystack_str.partition(needle_str) - return sep.empty? ? sep : after + sep.empty? ? sep : after end ## @@ -1265,7 +1265,7 @@ module Oga stop_index = -1 end - return haystack_str[start_index..stop_index] + haystack_str[start_index..stop_index] end ## @@ -1281,7 +1281,7 @@ module Oga # @return [Float] # def on_call_string_length(context, expression = nil) - return on_call_string(context, expression).length.to_f + on_call_string(context, expression).length.to_f end ## @@ -1301,7 +1301,7 @@ module Oga def on_call_normalize_space(context, expression = nil) str = on_call_string(context, expression) - return str.strip.gsub(/\s+/, ' ') + str.strip.gsub(/\s+/, ' ') end ## @@ -1330,7 +1330,7 @@ module Oga replaced = replaced.gsub(char, replace_with) end - return replaced + replaced end ## @@ -1360,7 +1360,7 @@ module Oga bool = !retval.respond_to?(:empty?) || !retval.empty? end - return bool + bool end ## @@ -1375,7 +1375,7 @@ module Oga # @return [TrueClass|FalseClass] # def on_call_not(context, expression) - return !on_call_boolean(context, expression) + !on_call_boolean(context, expression) end ## @@ -1387,7 +1387,7 @@ module Oga # @return [TrueClass] # def on_call_true(context) - return true + true end ## @@ -1399,7 +1399,7 @@ module Oga # @return [FalseClass] # def on_call_false(context) - return false + false end ## @@ -1428,7 +1428,7 @@ module Oga node = node.parent end - return false + false end ## @@ -1462,7 +1462,7 @@ module Oga sum += node.text.to_f end - return sum + sum end ## @@ -1478,7 +1478,7 @@ module Oga def on_call_floor(context, expression) number = on_call_number(context, expression) - return number.nan? ? number : number.floor.to_f + number.nan? ? number : number.floor.to_f end ## @@ -1494,7 +1494,7 @@ module Oga def on_call_ceiling(context, expression) number = on_call_number(context, expression) - return number.nan? ? number : number.ceil.to_f + number.nan? ? number : number.ceil.to_f end ## @@ -1510,7 +1510,7 @@ module Oga def on_call_round(context, expression) number = on_call_number(context, expression) - return number.nan? ? number : number.round.to_f + number.nan? ? number : number.round.to_f end ## @@ -1521,7 +1521,7 @@ module Oga # @return [Float] # def on_int(ast_node, context) - return ast_node.children[0].to_f + ast_node.children[0].to_f end ## @@ -1532,7 +1532,7 @@ module Oga # @return [Float] # def on_float(ast_node, context) - return ast_node.children[0] + ast_node.children[0] end ## @@ -1543,7 +1543,7 @@ module Oga # @return [String] # def on_string(ast_node, context) - return ast_node.children[0] + ast_node.children[0] end ## @@ -1586,7 +1586,7 @@ module Oga node = context.first end - return node + node end ## @@ -1597,7 +1597,7 @@ module Oga # @return [String] # def first_node_text(set) - return set[0].respond_to?(:text) ? set[0].text : '' + set[0].respond_to?(:text) ? set[0].text : '' end ## @@ -1614,7 +1614,7 @@ module Oga children.concat(xml_node.children) end - return children + children end ## @@ -1667,7 +1667,7 @@ module Oga xml_node.default_namespace? end - return name_matches && ns_matches + name_matches && ns_matches end ## @@ -1678,7 +1678,7 @@ module Oga def type_matches?(xml_node, ast_node) context = XML::NodeSet.new([xml_node]) - return process(ast_node, context).length > 0 + process(ast_node, context).length > 0 end ## @@ -1691,7 +1691,7 @@ module Oga def name_matches?(xml_node, name) return false unless xml_node.respond_to?(:name) - return name == STAR ? true : xml_node.name == name + name == STAR ? true : xml_node.name == name end ## @@ -1706,7 +1706,7 @@ module Oga return true if ns == STAR - return xml_node.namespace && xml_node.namespace.name == ns + xml_node.namespace && xml_node.namespace.name == ns end ## @@ -1714,7 +1714,7 @@ module Oga # @return [TrueClass|FalseClass] # def has_parent?(ast_node) - return ast_node.respond_to?(:parent) && !!ast_node.parent + ast_node.respond_to?(:parent) && !!ast_node.parent end ## @@ -1743,7 +1743,7 @@ module Oga value = value.to_i end - return value.to_s + value.to_s end ## @@ -1764,14 +1764,14 @@ module Oga @node_sets.pop - return retval + retval end ## # @return [Oga::XML::NodeSet] # def current_node_set - return @node_sets.last + @node_sets.last end ## @@ -1781,7 +1781,7 @@ module Oga # @return [Oga::XML::Node|Oga::XML::Document] # def root_node(node) - return node.respond_to?(:root_node) ? node.root_node : node + node.respond_to?(:root_node) ? node.root_node : node end ## @@ -1791,7 +1791,7 @@ module Oga # @return [Oga::XML::Node|Oga::XML::Document] # def parent_node(node) - return node.respond_to?(:parent) ? node.parent : node + node.respond_to?(:parent) ? node.parent : node end end # Evaluator end # XPath