Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- BX_INC="$(pwd -P)/src"
- . bxload
- ################
- # Acme::Animal #
- ################
- bx_package Acme::Animal
- _name(){
- echo "Hi, i'm ${FUNCNAME[1]} and i'm an animal."
- }
- _say(){
- echo -n "${FUNCNAME[1]}: "
- echo "${1:-"I say lorem ipsum"}"
- }
- bx_plug _name _say
- #####################
- # Acme::Animal::Dog #
- #####################
- bx_extends Acme::Animal with Dog
- _say(){
- echo -n "${FUNCNAME[1]}: "
- echo "${1:-"I say guau guau"}"
- }
- _moves(){
- echo "The dog ${FUNCNAME[1]} moves the ${1:-tail}."
- }
- bx_plug _moves _say
- ###########
- # Program #
- ###########
- bx_new Acme::Animal human
- human name
- human say
- bx_new Acme::Animal::Dog lola
- lola name # inerithed from Acme::Animal
- lola say # overwrited on Acme:Animal::Dog
- lola moves # new on Acme::Animal::Dog
- human say "Hi lola"
- lola say "I like meat"
- human say "OK, take it"
- lola moves "ears"
- # Output
- # inigo@crono:~/src/git/BX $ bash lola
- # Hi, i'm human and i'm an animal.
- # human: I say lorem ipsum
- # Hi, i'm lola and i'm an animal.
- # lola: I say guau guau
- # The dog lola moves the tail.
- # human: Hi lola
- # lola: I like meat
- # human: OK, take it
- # The dog lola moves the ears.
- # inigo@crono:~/src/git/BX $
Add Comment
Please, Sign In to add comment