Class: RubyToBlock::Block::Character
- Defined in:
- app/models/concerns/ruby_to_block/block/character.rb
Overview
ソースコードに含まれるキャラクターを表現するクラス
Instance Attribute Summary collapse
-
#angle ⇒ Object
Returns the value of attribute angle.
-
#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.
28 29 30 31 32 33 34 35 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 28 def initialize() @name = [:name] @costumes = [:costumes] @x = [:x] @y = [:y] @angle = [:angle] @rotation_style = [:rotation_style] end |
Instance Attribute Details
#angle ⇒ Object
Returns the value of attribute angle.
15 16 17 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 15 def angle @angle end |
#costumes ⇒ Object
Returns the value of attribute costumes.
12 13 14 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 12 def costumes @costumes end |
#name ⇒ Object
rubocop:enable LineLength
11 12 13 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 11 def name @name end |
#rotation_style ⇒ Object
Returns the value of attribute rotation_style.
16 17 18 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 16 def rotation_style @rotation_style end |
#x ⇒ Object
Returns the value of attribute x.
13 14 15 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 13 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
14 15 16 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 14 def y @y end |
Class Method Details
.process_match_data(md, context) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 18 def self.process_match_data(md, context) md2 = regexp.match(md[type]) name = md2[1] context[:characters][name] = new(name: name, costumes: [md2[2]], x: md2[3], y: md2[4], angle: md2[5], rotation_style: md2[6] || 'free') true end |
Instance Method Details
#to_xml(parent) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 37 def to_xml(parent) attrs = { 'name' => @name, 'x' => @x, 'y' => @y, 'angle' => @angle, 'costumes' => @costumes.join(',') } attrs['rotation_style'] = @rotation_style if @rotation_style != 'free' parent.add_element('character', attrs) end |