Sha256: f98a6eb215c7a28f6bcb22cef96ad15c30e48d0dc482afe4cd42b9e650515c27
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
# -*- coding: utf-8 -*- module RubyToBlock module Block # ソースコードに含まれるキャラクターを表現するクラス class Character < Base # rubocop:disable LineLength blocknize '^\s*(\S+)\s*=\s*Character\.new\(costume:\s*"(\s*[^"]+\s*)"\s*,\s*x:\s*(\s*\d+\s*)\s*,\s*y:\s*(\s*\d+\s*)\s*,\s*angle:\s*(\s*\d+\s*)(?:,\s*rotation_style:\s*\s*:(free|left_right|none)\s*)?\)\s*$', statement: true # rubocop:enable LineLength attr_accessor :name attr_accessor :costumes attr_accessor :x attr_accessor :y attr_accessor :angle attr_accessor :rotation_style 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 def initialize(options) @name = options[:name] @costumes = options[:costumes] @x = options[:x] @y = options[:y] @angle = options[:angle] @rotation_style = options[:rotation_style] end def to_xml(parent) attrs = { 'name' => @name, 'x' => @x, 'y' => @y, 'angle' => @angle, 'costumes' => @costumes.join(',') } attrs['rotationStyle'] = @rotation_style if @rotation_style != 'free' parent.add_element('character', attrs) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smalruby-editor-0.1.16-x86-mingw32 | app/models/concerns/ruby_to_block/block/character.rb |
smalruby-editor-0.1.16 | app/models/concerns/ruby_to_block/block/character.rb |