Module: Rabbit::Element::TextElement
Constant Summary
Constants included from GetText
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Attributes included from TextRenderer
#first_line_height, #first_line_width, #indent, #layout, #original_height, #original_width, #wrap_mode
Attributes included from Base
#base_h, #base_w, #base_x, #base_y, #default_margin_bottom, #default_margin_left, #default_margin_right, #default_margin_top, #default_padding_bottom, #default_padding_left, #default_padding_right, #default_padding_top, #default_visible, #h, #horizontal_centering, #margin_bottom, #margin_left, #margin_right, #margin_top, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #ph, #pw, #px, #py, #real_simulation, #user_property, #vertical_centering, #w, #x, #y
Instance Method Summary collapse
- #draw_element(canvas, x, y, w, h, simulation) ⇒ Object
- #empty? ⇒ Boolean
- #initialize(text) ⇒ Object
- #inspect(verbose = false) ⇒ Object
- #substitute_text ⇒ Object
- #to_html(generator) ⇒ Object
Methods included from TextRenderer
#align=, #as_large_as_possible, #clear_theme, #compile, #dirty!, #dirty?, #do_horizontal_centering, #do_horizontal_centering?, #font_size, #have_numerical_font_size?, #height, #justify=, #keep_in_size, #markuped_text, #pixel_font_size, #reset_horizontal_centering, #spacing=, #text_clear_theme, #text_compile, #text_dirty?, #text_props, #text_renderer?, #text_to_html, #width
Methods included from Base
#[], #[]=, #add_default_prop, #adjust_x_centering, #adjust_y_margin, #adjust_y_padding, #available_w, #centering_adjusted_height, #centering_adjusted_width, #clear_margin, #clear_padding, #clear_theme, #clone, #compile, #compile_element, #compile_for_horizontal_centering, #compile_horizontal, #default_prop, #dirty!, #dirty?, #do_horizontal_centering, #do_horizontal_centering?, #do_vertical_centering?, #draw, #font, #have_tag?, #have_wait_tag?, #height, #hide, #if_dirty, #init_default_margin, #init_default_padding, #init_default_visible, #inline_element?, #margin_set, #margin_with, #match?, #next_element, #padding_set, #padding_with, #previous_element, #prop_delete, #prop_get, #prop_set, #prop_value, #reset_horizontal_centering, #restore_x_margin, #restore_x_padding, #setup_margin, #setup_padding, #show, #slide, #substitute_newline, #text_renderer?, #visible?, #wait, #width
Methods included from Base::DrawHook
#clear_draw_procs, def_draw_hook, def_draw_hooks
Methods included from Utils
arg_list, collect_classes_under_module, collect_modules_under_module, collect_under_module, combination, compute_bottom_y, compute_left_x, compute_right_x, compute_top_y, corresponding_class_under_module, corresponding_module_under_module, corresponding_objects, ensure_time, events_pending_available?, extract_four_way, find_path_in_load_path, init_by_constants_as_default_value, move_to, move_to_bottom_left, move_to_bottom_right, move_to_top_left, move_to_top_right, parse_four_way, process_pending_events, process_pending_events_proc, quartz?, require_files_under_directory_in_load_path, require_safe, split_number_to_minute_and_second, stringify_hash_key, support_console_input?, support_console_output?, syntax_highlighting_debug?, time, to_class_name, unescape_title, windows?
Methods included from GetText
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/rabbit/element/text-element.rb', line 8 def text @text end |
Instance Method Details
#draw_element(canvas, x, y, w, h, simulation) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rabbit/element/text-element.rb', line 43 def draw_element(canvas, x, y, w, h, simulation) unless simulation draw_layout(canvas, x, y) end [x + width, y, w - width, h] end |
#empty? ⇒ Boolean
54 55 56 |
# File 'lib/rabbit/element/text-element.rb', line 54 def empty? @text.nil? or /\A\s*\z/ =~ @text end |
#initialize(text) ⇒ Object
10 11 12 13 |
# File 'lib/rabbit/element/text-element.rb', line 10 def initialize(text) super() @text = text end |
#inspect(verbose = false) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/rabbit/element/text-element.rb', line 58 def inspect(verbose=false) if verbose super() else "<#{self.class.name} #{@text.inspect}>" end end |
#substitute_text ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rabbit/element/text-element.rb', line 22 def substitute_text result = yield(@text.dup) return false if result == @text case result when Array new_elements = result.collect do |element| if element.is_a?(Base) element else new_element = clone new_element.text = element new_element end end parent.replace_element(self, *new_elements) else self.text = result end true end |
#to_html(generator) ⇒ Object
50 51 52 |
# File 'lib/rabbit/element/text-element.rb', line 50 def to_html(generator) text_to_html(generator) end |