MCPcopy Create free account
hub / github.com/aspizu/goboscript / value_input

Method value_input

src/codegen/input.rs:134–163  ·  view source on GitHub ↗
(&mut self, name: &str, value: &Value)

Source from the content-addressed store, hash-verified

132 }
133
134 fn value_input(&mut self, name: &str, value: &Value) -> io::Result<()> {
135 match value {
136 Value::Boolean(boolean) => {
137 write!(self, "[1,[4,{}]]", json!(*boolean as i64))
138 }
139 Value::Number(number) if number.fract() == 0.0 => {
140 write!(self, "[1,[4,{}]]", json!(number))
141 }
142 Value::Number(number) => {
143 write!(self, "[1,[4,{}]]", json!(number))
144 }
145 Value::String(string) => {
146 let color = ["COLOR", "COLOR2"]
147 .contains(&name)
148 .then(|| {
149 csscolorparser::parse(string)
150 .ok()
151 .filter(|color| color.a == 1.0)
152 })
153 .flatten();
154 if name == "BROADCAST_INPUT" {
155 write!(self, "[1,[11,{},{}]]", json!(**string), json!(**string))
156 } else if let Some(color) = color {
157 write!(self, "[1,[9,{}]]", json!(color.to_hex_string()))
158 } else {
159 write!(self, "[1,[10,{}]]", json!(**string))
160 }
161 }
162 }
163 }
164
165 fn name_input(
166 &mut self,

Callers 1

_inputMethod · 0.80

Calls 1

parseFunction · 0.50

Tested by

no test coverage detected