Class: VectorBeWinding::Drawable

Inherits:
Object
  • Object
show all
Defined in:
lib/vector_be_winding/drawable.rb

Instance Method Summary collapse

Instance Method Details

#be_windingObject



27
28
29
30
31
32
33
34
35
36
37
# 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

#dumpObject



50
51
52
53
54
55
56
57
58
59
# 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_windingObject



39
40
41
42
43
44
45
46
47
48
# 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) ⇒ Object



13
14
15
# File 'lib/vector_be_winding/drawable.rb', line 13

def read(inio)
  @document = REXML::Document.new inio
end

#read_from_file(filename) ⇒ Object

A class to handle Android’s vector drawable



7
8
9
10
11
# File 'lib/vector_be_winding/drawable.rb', line 7

def read_from_file(filename)
  open(filename) { |inio|
    read(inio)
  }
end

#write(outio) ⇒ Object



23
24
25
# File 'lib/vector_be_winding/drawable.rb', line 23

def write(outio)
  @document.write outio
end

#write_to_file(filename) ⇒ Object



17
18
19
20
21
# File 'lib/vector_be_winding/drawable.rb', line 17

def write_to_file(filename)
  open(filename, 'w') {|outio|
    write(outio)
  }
end