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.
-
#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.
26 27 28 29 30 31 32 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 26 def initialize() @name = [:name] @costumes = [:costumes] @x = [:x] @y = [:y] @angle = [:angle] 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 |
#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
17 18 19 20 21 22 23 24 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 17 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]) true end |
Instance Method Details
#to_xml(parent) ⇒ Object
34 35 36 37 38 39 |
# File 'app/models/concerns/ruby_to_block/block/character.rb', line 34 def to_xml(parent) parent.add_element('character', 'name' => @name, 'x' => @x, 'y' => @y, 'angle' => @angle, 'costumes' => @costumes.join(',')) end |