Class: DroidProj::Android::DrawableState
- Inherits:
-
Object
- Object
- DroidProj::Android::DrawableState
- Defined in:
- lib/droidproj/drawable_state.rb
Instance Attribute Summary collapse
-
#drawable ⇒ Object
Android::Drawable instance this state is for.
-
#file_path ⇒ Object
String original path of the image file.
-
#size ⇒ Object
Symbol for what size folder this goes into.
-
#state ⇒ Object
Hash of options which define what android:state this is for.
Instance Method Summary collapse
- #final_drawable_name ⇒ Object
- #final_extension ⇒ Object
- #final_file_name ⇒ Object
-
#initialize ⇒ DrawableState
constructor
A new instance of DrawableState.
- #xml_string ⇒ Object
Constructor Details
#initialize ⇒ DrawableState
Returns a new instance of DrawableState.
15 16 17 |
# File 'lib/droidproj/drawable_state.rb', line 15 def initialize @state = {} end |
Instance Attribute Details
#drawable ⇒ Object
Android::Drawable instance this state is for
13 14 15 |
# File 'lib/droidproj/drawable_state.rb', line 13 def drawable @drawable end |
#file_path ⇒ Object
String original path of the image file
11 12 13 |
# File 'lib/droidproj/drawable_state.rb', line 11 def file_path @file_path end |
#size ⇒ Object
Symbol for what size folder this goes into
9 10 11 |
# File 'lib/droidproj/drawable_state.rb', line 9 def size @size end |
#state ⇒ Object
Hash of options which define what android:state this is for
7 8 9 |
# File 'lib/droidproj/drawable_state.rb', line 7 def state @state end |
Instance Method Details
#final_drawable_name ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/droidproj/drawable_state.rb', line 32 def final_drawable_name final_file_name = DroidProj::Android::Drawable::FINAL_FILE_PREFIX + self.drawable.name self.state.each do |state, value| final_file_name << "_#{state}_#{value}" end final_file_name end |
#final_extension ⇒ Object
40 41 42 43 |
# File 'lib/droidproj/drawable_state.rb', line 40 def final_extension file_name = Pathname.new(self.file_path).basename file_name.to_s.split('.')[1..-1].join('.') end |
#final_file_name ⇒ Object
28 29 30 |
# File 'lib/droidproj/drawable_state.rb', line 28 def final_file_name final_drawable_name + "." + final_extension end |
#xml_string ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/droidproj/drawable_state.rb', line 19 def xml_string str = "<item " self.state.each do |state, value| str << "android:state_#{state}=\"#{value}\" " end str << "android:drawable=\"@drawable/#{final_drawable_name}\" />" end |