Class: Teepee::Commander

Direct Known Subclasses

ActionableCommander

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Teepee::CommanderMixins::ThinkingBicycleModels

#bookmarks_folder_id, #folder_id, #forum_id, #id_command_handler, #image, #keyword_id, #link, #link_id, #mailto, #note_id, #tag_id, #tb_href, #user

Methods included from Teepee::CommanderMixins::Mathematics

#%, #*, #**, #+, #-, #/, #acos, #acosh, #add_percentage, #asin, #asinh, #atan, #atanh, #ceiling, #cos, #cosh, #degrees2radians, #e, #ensure_numeric, #erf, #erfc, #floor, #gamma, #greater_than, #greater_than_or_equal, #hypot, #i, #ld, #ldexp, #less_than, #less_than_or_equal, #lgamma, #ln, #log, #log10, #mod, #non_numeric_error, #number_from_word, #numeric?, #percent_total, #pi, #radians2degrees, #round, #sin, #sinh, #sqrt, #subtract_percentage, #tan, #tanh, #to_numbers

Methods included from Teepee::CommanderMixins::Formatting

#b, #big, #br, #del, #enumerate, #enumerate_lowercase, #enumerate_numeric, #enumerate_roman_lowercase, #enumerate_roman_uppercase, #enumerate_uppercase, #h1, #h2, #h3, #h4, #h5, #h6, #html_tag, #it, #item, #itemize, #itemize_circle, #itemize_disc, #itemize_none, #itemize_square, #nbsp, #small, #span_operator, #sub, #sup, #table, #table_data, #table_header, #table_row, #tt, #u

Methods included from Teepee::CommanderMixins::Control

#case_operator, #comment, #cond_operator, #decrement, #define, #dotimes, #equal, #get_operator, #if_operator, #increment, #is_defined?, #is_scoped?, #let1, #not_equal, #prog1_operator, #progn_operator, #prognil, #undefine, #unless_operator, #update_scopes, #update_variable, #when_operator

Methods included from Teepee::CommanderMixins::Boolean

#boolean_and, #boolean_nand, #boolean_nor, #boolean_not, #boolean_or, #boolean_xnor, #boolean_xor, #ensure_boolean, #false_constant, #false_constant?, #true_constant, #true_constant?

Constructor Details

#initialize(params) ⇒ Commander

Returns a new instance of Commander.



54
55
56
# File 'lib/teepee/commander.rb', line 54

def initialize params
  # We don't use the params in the base class, but might in derived classes.
end

Instance Attribute Details

#parserObject

Returns the value of attribute parser.



52
53
54
# File 'lib/teepee/commander.rb', line 52

def parser
  @parser
end

#scopeObject

Returns the value of attribute scope.



52
53
54
# File 'lib/teepee/commander.rb', line 52

def scope
  @scope
end

Instance Method Details

#backquoteObject



107
108
109
# File 'lib/teepee/commander.rb', line 107

def backquote
  "`"
end

#backslashObject



111
112
113
# File 'lib/teepee/commander.rb', line 111

def backslash
  "\\"
end

#command_error(message) ⇒ Object



69
70
71
# File 'lib/teepee/commander.rb', line 69

def command_error message
  %{<span style="color: red">[#{message}]</span>}
end

#command_not_yet_implemented(command) ⇒ Object



73
74
75
# File 'lib/teepee/commander.rb', line 73

def command_not_yet_implemented command
  command_error "The command #{command} is not yet implemented."
end

#dollarObject



115
116
117
# File 'lib/teepee/commander.rb', line 115

def dollar
  "$"
end

#left_braceObject



119
120
121
# File 'lib/teepee/commander.rb', line 119

def left_brace
  "{"
end

#left_bracketObject



123
124
125
# File 'lib/teepee/commander.rb', line 123

def left_bracket
  "["
end

#left_strip(expressions) ⇒ Object



81
82
83
84
85
86
# File 'lib/teepee/commander.rb', line 81

def left_strip expressions
  while expressions.first.kind_of? WhitespaceToken
    expressions.shift
  end
  expressions
end

#pipeObject



127
128
129
# File 'lib/teepee/commander.rb', line 127

def pipe
  "|"
end

#pipe?(expression) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/teepee/commander.rb', line 103

def pipe? expression
  expression.is_a? PipeToken
end

#right_braceObject



131
132
133
# File 'lib/teepee/commander.rb', line 131

def right_brace
  "}"
end

#right_bracketObject



135
136
137
# File 'lib/teepee/commander.rb', line 135

def right_bracket
  "]"
end

#right_strip(expressions) ⇒ Object



88
89
90
91
92
93
# File 'lib/teepee/commander.rb', line 88

def right_strip expressions
  while expressions.last.kind_of? WhitespaceToken
    expressions.pop
  end
  expressions
end

#spaceObject



143
144
145
# File 'lib/teepee/commander.rb', line 143

def space
  " "
end

#squiggleObject



139
140
141
# File 'lib/teepee/commander.rb', line 139

def squiggle
  "~"
end

#strip(expressions) ⇒ Object



95
96
97
# File 'lib/teepee/commander.rb', line 95

def strip expressions
  left_strip right_strip expressions
end

#valid_email_address?(email_address) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/teepee/commander.rb', line 99

def valid_email_address? email_address
  email_address =~ /\A[[:graph:]]+@[\w._-]+\z/
end

#valid_uri?(uri) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
66
67
# File 'lib/teepee/commander.rb', line 63

def valid_uri? uri
  (!! (u = URI.parse(uri))) and not u.scheme.nil?
rescue URI::InvalidURIError
  false
end

#variable_not_defined_error(variable) ⇒ Object



77
78
79
# File 'lib/teepee/commander.rb', line 77

def variable_not_defined_error variable
  command_error "The variable \"#{variable}\" is not defined."
end

#with_scope(scope) ⇒ Object



58
59
60
61
# File 'lib/teepee/commander.rb', line 58

def with_scope scope
  @scope = scope
  self
end