Guest User

Untitled

a guest
Jan 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. BX_INC="$(pwd -P)/src"
  4.  
  5. . bxload
  6.  
  7. ################
  8. # Acme::Animal #
  9. ################
  10. bx_package Acme::Animal
  11.  
  12. _name(){
  13. echo "Hi, i'm ${FUNCNAME[1]} and i'm an animal."
  14. }
  15.  
  16. _say(){
  17. echo -n "${FUNCNAME[1]}: "
  18. echo "${1:-"I say lorem ipsum"}"
  19. }
  20.  
  21. bx_plug _name _say
  22.  
  23. #####################
  24. # Acme::Animal::Dog #
  25. #####################
  26. bx_extends Acme::Animal with Dog
  27.  
  28. _say(){
  29. echo -n "${FUNCNAME[1]}: "
  30. echo "${1:-"I say guau guau"}"
  31. }
  32.  
  33. _moves(){
  34. echo "The dog ${FUNCNAME[1]} moves the ${1:-tail}."
  35. }
  36.  
  37. bx_plug _moves _say
  38.  
  39. ###########
  40. # Program #
  41. ###########
  42. bx_new Acme::Animal human
  43.  
  44. human name
  45. human say
  46.  
  47. bx_new Acme::Animal::Dog lola
  48.  
  49. lola name # inerithed from Acme::Animal
  50. lola say # overwrited on Acme:Animal::Dog
  51. lola moves # new on Acme::Animal::Dog
  52.  
  53. human say "Hi lola"
  54. lola say "I like meat"
  55. human say "OK, take it"
  56. lola moves "ears"
  57.  
  58.  
  59. # Output
  60. # inigo@crono:~/src/git/BX $ bash lola
  61. # Hi, i'm human and i'm an animal.
  62. # human: I say lorem ipsum
  63. # Hi, i'm lola and i'm an animal.
  64. # lola: I say guau guau
  65. # The dog lola moves the tail.
  66. # human: Hi lola
  67. # lola: I like meat
  68. # human: OK, take it
  69. # The dog lola moves the ears.
  70. # inigo@crono:~/src/git/BX $
Add Comment
Please, Sign In to add comment