Class: Cyberweb::CssManager

Inherits:
Base
  • Object
show all
Defined in:
lib/cyberweb/css_manager/css_manager.rb

Overview

Cyberweb::CssManager

Constant Summary

Constants inherited from Base

Base::HOME_DIRECTORY_OF_THE_USER_X, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#be_verbose, #be_verbose?, #cascading_style_sheets_directory?, #cd, #commandline_mode?, #copyright?, #css_comment, #delete_directory, #do_toggle, #e, #echo_raw, #filename?, #full_path_to_image_directory?, #html_colours?, #html_image, #htmlentities, #img_dir?, #infer_the_namespace, #initialize_the_configuration, #is_a_file?, #is_a_video_file?, #is_an_image_file?, #is_on_roebe?, #last_tag_used?, #last_tag_used_first_element?, #last_tag_used_id?, #mkdir, #mode?, #namespace?, #open_in_browser, #opne, #opnn, #remove_comments_from_this_string_but_preserve_CSS_rules, #remove_html, #return_all_directories, #return_date, #return_program_name, #return_pwd, #ruby_header?, #server_base_directory?, #set_commandline_mode, #set_last_tag_used, #update_the_image_directory, #use_this_relative_directory_for_custom_images?, #www_mode?

Methods included from BaseModule::FileRelatedFunctionality

#copy_this_file, #cpr, #delete_file, #filename_without_extension?, #read_file_via_utf8_encoding

Methods included from BaseModule

#attach_these_constants, #base_dir?, #beautiful_url, #cd, #create_the_internal_hash, #doctype?, #ee, #ensure_main_encoding, #esystem, #html_templates, #initialize_the_config_if_the_config_hash_is_empty, #internal_hash?, #log_dir?, #no_http, #random_alphabet_characters, #rarrow?, #rds, #remove_comments_from_this_string, #remove_numbers, #require_the_html_templates, #require_these, #return_file_size_in_kb_of, #return_html_comment, #ruby_sitelib_dir?, #sanitize_this_id, #server_base_directory?, #string_remote_image, #today?, #try_to_require_rack, #try_to_require_the_open_gem, #write_what_into

Methods included from BaseModule::ContentType

#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text

Methods included from BaseModule::CommandlineArguments

#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments

Methods included from BaseModule::Colours

#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ CssManager

#

initialize

#


31
32
33
34
35
36
37
38
39
40
# File 'lib/cyberweb/css_manager/css_manager.rb', line 31

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Cyberweb::CssManager[]

#


184
185
186
# File 'lib/cyberweb/css_manager/css_manager.rb', line 184

def self.[](i = ARGV)
  new(i)
end

Instance Method Details

#add(i) ⇒ Object

#

add (add tag)

#


57
58
59
# File 'lib/cyberweb/css_manager/css_manager.rb', line 57

def add(i)
  @result << i
end

#css_rule_for_drop_shadow(use_this_colour = :steelblue, n_px_width = 5) ⇒ Object

#

css_rule_for_drop_shadow

This method can be used to generate a drop-shadow effect for text.

Usage example:

css_rule_for_drop_shadow(:steelblue)
#


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/cyberweb/css_manager/css_manager.rb', line 150

def css_rule_for_drop_shadow(
    use_this_colour = :steelblue,
    n_px_width      = 5
  )
  use_this_colour = use_this_colour.to_s.delete(':')
  add '/* drop-shadow effect */
  .drop_shadow_'+use_this_colour+' {
    filter: drop-shadow('+
            n_px_width.to_s+'px '+
            n_px_width.to_s+'px '+
            n_px_width.to_s+'px '+use_this_colour+');
  }

  '
end

#css_rule_for_hover_pulse_grow(iterate_n_times = :infinite, use_this_as_the_CSS_class_name = 'hover_pulse_grow') ⇒ Object

#

css_rule_for_hover_pulse_grow

This method can be used to generate an ad-hoc pulse-grow CSS rule.

Usage example:

css_rule_for_hover_pulse_grow(5)
#


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/cyberweb/css_manager/css_manager.rb', line 71

def css_rule_for_hover_pulse_grow(
    iterate_n_times                = :infinite,
    use_this_as_the_CSS_class_name = 'hover_pulse_grow'
  )
  case iterate_n_times
  # ======================================================================= #
  # === :infinity
  # ======================================================================= #
  when :infinity,
       :default,
       nil # This is also the default entry point.
    iterate_n_times = :infinite
  end
  iterate_n_times = iterate_n_times.to_s
  # ======================================================================= #
  # Add Pulse Grow next:
  # ======================================================================= #
  add '/* Pulse Grow */
@-webkit-keyframes '+use_this_as_the_CSS_class_name.to_s+' {
to {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}
}
@keyframes '+use_this_as_the_CSS_class_name.to_s+' {
to {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}
}
.'+use_this_as_the_CSS_class_name.to_s+' {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
}
.'+use_this_as_the_CSS_class_name.to_s+':hover,
.'+use_this_as_the_CSS_class_name.to_s+':focus,
.'+use_this_as_the_CSS_class_name.to_s+':active {
-webkit-animation-name: '+use_this_as_the_CSS_class_name.to_s+';
animation-name: '+use_this_as_the_CSS_class_name.to_s+';
-webkit-animation-duration: 0.3s;
animation-duration: 0.3s;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
-webkit-animation-direction: alternate;
animation-direction: alternate;

-webkit-animation-iteration-count: '+iterate_n_times+'; /* or infinite; */
animation-iteration-count:         '+iterate_n_times+'; /* or infinite; */
}'
end

#evaluate_this_block(&block) ⇒ Object

#

evaluate_this_block

#


169
170
171
172
173
# File 'lib/cyberweb/css_manager/css_manager.rb', line 169

def evaluate_this_block(&block)
  if block_given?
    eval(yield)
  end
end

#resetObject

#

reset (reset tag)

#


45
46
47
48
49
50
51
52
# File 'lib/cyberweb/css_manager/css_manager.rb', line 45

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @result
  # ======================================================================= #
  @result = ''.dup
end

#result_as_CSS_style?Boolean

#

result_as_CSS_style?

#

Returns:

  • (Boolean)


136
137
138
# File 'lib/cyberweb/css_manager/css_manager.rb', line 136

def result_as_CSS_style?
  "<style>\n#{result?}\n</style>"
end

#runObject

#

run (run tag)

#


178
179
# File 'lib/cyberweb/css_manager/css_manager.rb', line 178

def run
end

#to_strObject Also known as: to_s, result?

#

to_str

#


128
129
130
# File 'lib/cyberweb/css_manager/css_manager.rb', line 128

def to_str
  @result.to_s
end