class VectorBeWinding::Drawable

Public Instance Methods

be_winding() click to toggle source
# File lib/vector_be_winding/drawable.rb, line 27
def be_winding
   @document.each_recursive {|node|
     if node.name == 'path'
       pathString = node.attributes['android:pathData']
       path = Path.with_string(pathString)
       newPath = path.be_winding

       node.add_attribute('android:pathData', newPath.to_command)
     end
   }
 end
dump() click to toggle source
# File lib/vector_be_winding/drawable.rb, line 50
def dump
  @document.each_recursive {|node|
    if node.name == 'path'
      pathString = node.attributes['android:pathData']
      path = Path.with_string(pathString)
      puts "Path"
      path.dump(1)
    end
  }
end
is_winding() click to toggle source
# File lib/vector_be_winding/drawable.rb, line 39
def is_winding
  @document.each_recursive {|node|
    if node.name == 'path'
      pathString = node.attributes['android:pathData']
      path = Path.with_string(pathString)
      return false if !path.is_winding
    end
  }
  true
end
read(inio) click to toggle source
# File lib/vector_be_winding/drawable.rb, line 13
def read(inio)
  @document = REXML::Document.new inio
end
read_from_file(filename) click to toggle source

A class to handle Android's vector drawable

# File lib/vector_be_winding/drawable.rb, line 7
def read_from_file(filename)
  open(filename) { |inio|
    read(inio)
  }
end
write(outio) click to toggle source
# File lib/vector_be_winding/drawable.rb, line 23
def write(outio)
  @document.write outio
end
write_to_file(filename) click to toggle source
# File lib/vector_be_winding/drawable.rb, line 17
def write_to_file(filename)
  open(filename, 'w') {|outio|
    write(outio)
  }
end