Thread: Inner Classes In Ruby?

Results 1 to 4 of 4
  1. #1 Inner Classes In Ruby? 
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,335
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    Any way to do this?
    Code:
                character.startAction(new DistancedAction(1, true, character, object_position, 1) {
                    @Override
                    public void executeAction() {
                        character.teleport(pos);
                        stop();
                    }
                });
    In ruby?

    Getting tired of making separate action classes.
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jul 2013
    Posts
    64
    Thanks given
    0
    Thanks received
    85
    Rep Power
    0
    if you are trying to make an actual inner class in Ruby, i am not sure, but if you want an anonymous function (which is what it looks like what you want to do), look at this web page

    Understanding Ruby Blocks, Procs and Lambdas - Robert Sosinski
    Reply With Quote  
     

  3. #3  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,335
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    Ya that's along the lines of what I'm looking for. Thanks.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,335
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    I kinda figured out what I wanted by editing the bootstrap file in apollo.

    Code:
        bind_distance_action 1, true, player, event.position, 1 do |action|
          player.teleport(STAIRS[event.id].position);
          action.stop
        end
    Code:
    class ProcDistancedAction < DistancedAction
      def initialize(block, delay, immediate, player, position, distance)
        super delay, immediate, player, position, distance
        @block = block
      end
    
      def executeAction
        @block.call self
      end
    end
    
    def bind_distance_action(*args, &block)
      if block_given?
        args[2].startAction ProcDistancedAction.new(block, args[0], args[1], args[2], args[3], args[4])
      end
    end
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Java Class, In need of help
    By VeRoCo in forum Application Development
    Replies: 12
    Last Post: 11-11-2010, 02:21 PM
  2. Load classes in directory
    By Mrquarterx in forum Application Development
    Replies: 27
    Last Post: 04-23-2010, 12:11 AM
  3. must be final..access...inner class
    By Senqi in forum Help
    Replies: 4
    Last Post: 02-07-2010, 09:05 PM
  4. animation class in non-renamed?
    By Slay No More in forum Help
    Replies: 3
    Last Post: 08-05-2009, 06:00 AM
  5. Connection handler in ruby..
    By pregg in forum Tutorials
    Replies: 0
    Last Post: 09-04-2007, 02:51 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •