diff --git a/bin/ruby2gv b/bin/ruby2gv index 15bc148..40ea36d 100755 --- a/bin/ruby2gv +++ b/bin/ruby2gv @@ -106,7 +106,7 @@ class Rb2Gv def parseFile( xFile, xFromFile = nil, xLib = nil ) - if xFromFile.nil? == false + if xFromFile puts "Parse #{xFile} required in #{xFromFile} :" if DEBUG else puts "Parse #{xFile} :" if DEBUG @@ -120,11 +120,11 @@ class Rb2Gv if lxLineMatch = REQUIRE.match( xLine ) xRequiredLib = lxLineMatch[2].gsub( /\.(rb|so)$/, "" ) - if @hxNodes.has_key?( xRequiredLib ) == false + if not @hxNodes.has_key?( xRequiredLib ) puts " + Node #{xRequiredLib}" if DEBUG xRequiredFile = getLibraryPath( xRequiredLib ) - if xRequiredFile.nil? == false + if xRequiredFile unless @lxStops.include?(xRequiredLib) @hxNodes[xRequiredLib] = gv_newNode( xRequiredLib ) parseFile( xRequiredFile, xFile, xRequiredLib ) diff --git a/lib/graphviz.rb b/lib/graphviz.rb index 12af9fc..501ef22 100644 --- a/lib/graphviz.rb +++ b/lib/graphviz.rb @@ -131,7 +131,7 @@ def add_nodes(node_name, options = {}) def get_node( xNodeName, &block ) node = @hoNodes[xNodeName] || nil - yield( node ) if( block and node.nil? == false ) + yield( node ) if( block and node ) return node end @@ -298,7 +298,7 @@ def add_graph( xGraphName = nil, hOpts = {}, &block ) def get_graph( xGraphName, &block ) graph = @hoGraphs[xGraphName] || nil - yield( graph ) if( block and graph.nil? == false ) + yield( graph ) if( block and graph ) return graph end @@ -499,7 +499,7 @@ def output( hOpts = {} ) end xDOTScript << "}" - if @oParentGraph.nil? == false + if @oParentGraph xDOTScript = "subgraph #{GraphViz.escape(@name, :unquote_empty => true)} {\n" << xDOTScript return( xDOTScript ) @@ -776,7 +776,7 @@ def self.options( hOpts ) # def self.parse( xFile, hOpts = {}, &block ) graph = Dot2Ruby::new( hOpts[:path], nil, nil ).eval( xFile ) - yield( graph ) if( block and graph.nil? == false ) + yield( graph ) if( block and graph ) return graph end @@ -790,7 +790,7 @@ def self.parse( xFile, hOpts = {}, &block ) # def self.parse_string( str, hOpts = {}, &block ) graph = Dot2Ruby::new( hOpts[:path], nil, nil ).eval_string( str ) - yield( graph ) if( block and graph.nil? == false ) + yield( graph ) if( block and graph ) return graph end diff --git a/lib/graphviz/attrs.rb b/lib/graphviz/attrs.rb index b519b4d..92b881a 100644 --- a/lib/graphviz/attrs.rb +++ b/lib/graphviz/attrs.rb @@ -44,9 +44,6 @@ def []( key ) self[k] = v end else - if @data.key?( key.to_s ) == false - nil - end @data[key.to_s] end end @@ -66,12 +63,10 @@ def []=( key, value ) rescue => e raise AttributeException, "Invalide value `#{value}` for attribute `#{key}` : #{e}" end - unless value.nil? - @data[key.to_s] = value - if @graphviz.nil? == false - @graphviz.set_position( @name, key.to_s, @data[key.to_s] ) - end + if value + @data[key.to_s] = value + @graphviz.set_position( @name, key.to_s, @data[key.to_s] ) if @graphviz end end end diff --git a/lib/graphviz/edge.rb b/lib/graphviz/edge.rb index c51f8cb..dd9b256 100644 --- a/lib/graphviz/edge.rb +++ b/lib/graphviz/edge.rb @@ -45,7 +45,7 @@ def initialize( vNodeOne, vNodeTwo, parent_graph ) # Return the node one as string (so with port if any) def node_one( with_port = true ) - if @node_one_port.nil? or with_port == false + if not (@node_one_port and with_port) GraphViz.escape(@node_one_id) else GraphViz.escape(@node_one_id, :force => true) + ":#{@node_one_port}" @@ -55,7 +55,7 @@ def node_one( with_port = true ) # Return the node two as string (so with port if any) def node_two( with_port = true ) - if @node_two_port.nil? or with_port == false + if not (@node_two_port and with_port) GraphViz.escape(@node_two_id) else GraphViz.escape(@node_two_id, :force => true) + ":#{@node_two_port}" diff --git a/lib/graphviz/xml.rb b/lib/graphviz/xml.rb index 118d3f5..27158ed 100644 --- a/lib/graphviz/xml.rb +++ b/lib/graphviz/xml.rb @@ -49,7 +49,7 @@ def initialize( xml_file, *options ) @show_text = true @show_attributes = true - if options.nil? == false and options[0].nil? == false + if options and options[0] options[0].each do |xKey, xValue| case xKey.to_s when "text" @@ -74,11 +74,11 @@ def parse_xml_node( xml_node ) #:nodoc: label = xml_node.name if xml_node.has_attributes? and @show_attributes label = "{ " + xml_node.name - + xml_node.attributes.each do |xName, xValue| label << "| { #{xName} | #{xValue} } " end - + label << "}" end @graph.add_nodes( local_node_name, "label" => label, "color" => "blue", "shape" => "record" )