Class: RubyToBlock::Block::Character
- Defined in:
- app/models/concerns/ruby_to_block/block/character.rb
Overview
ソースコードに含まれるキャラクターを表現するクラス
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#angle ⇒ Object
Returns the value of attribute angle.
-
#costume_index ⇒ Object
Returns the value of attribute costume_index.
-
#costumes ⇒ Object
Returns the value of attribute costumes.
-
#name ⇒ Object
rubocop:enable LineLength.
-
#rotation_style ⇒ Object
Returns the value of attribute rotation_style.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Attributes inherited from Base
#fields, #parent, #prev_sibling, #sibling, #statements, #values
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Character
constructor
A new instance of Character.
- #to_xml(parent) ⇒ Object
Methods inherited from Base
#[], #add_statement, #add_value, blocknize, indent?, #indent_level, inherited, inline?, #inline?, #null?, priority, process_else, process_end, process_value_string, regexp, statement?, #type, type, value?
Constructor Details
#initialize(options) ⇒ Character
Returns a new instance of Character.
43 44 45 46 47 48 49 50 51 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 43 def initialize() @name = [:name] @costumes = [:costumes] @costume_index = [:costume_index] @x = [:x] @y = [:y] @angle = [:angle] @rotation_style = [:rotation_style] end |
Instance Attribute Details
#angle ⇒ Object
Returns the value of attribute angle.
25 26 27 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 25 def angle @angle end |
#costume_index ⇒ Object
Returns the value of attribute costume_index.
22 23 24 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 22 def costume_index @costume_index end |
#costumes ⇒ Object
Returns the value of attribute costumes.
21 22 23 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 21 def costumes @costumes end |
#name ⇒ Object
rubocop:enable LineLength
20 21 22 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 20 def name @name end |
#rotation_style ⇒ Object
Returns the value of attribute rotation_style.
26 27 28 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 26 def rotation_style @rotation_style end |
#x ⇒ Object
Returns the value of attribute x.
23 24 25 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 23 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
24 25 26 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 24 def y @y end |
Class Method Details
.process_match_data(md, context) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 28 def self.process_match_data(md, context) md2 = regexp.match(md[type]) name = md2[1] costumes = md2[2].scan(/"([^"]+)"/).flatten context[:characters][name] = new(name: name, costumes: costumes, costume_index: md2[3] || "0", x: md2[4], y: md2[5], angle: md2[6], rotation_style: md2[7] || "free") true end |
Instance Method Details
#to_xml(parent) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 53 def to_xml(parent) attrs = { "name" => @name, "x" => @x, "y" => @y, "angle" => @angle, "costumes" => @costumes.join(","), } if @costume_index != "0" attrs["costume_index"] = @costume_index end if @rotation_style != "free" attrs["rotation_style"] = @rotation_style end parent.add_element("character", attrs) end |